· 6 years ago · Feb 07, 2020, 10:00 PM
1Date: 2020-02-07 22:54:54
2ID: 3
3Error occured in: Global
4Count: 1
5Message: [string "_G['HFToken']='6d132407b753b0f1803be4a52e2f9d90';..."] line 14208:
6 '=' expected near 'function'
7Debug:
8 [string "=[C]"]: ?
9 [string "=[C]"]: ?
10 [string "EWT = {}
11
12 local version, internalVersion, date, uiVersion = GetBuildInfo()
13 EWT.wowBuild = tonumber(internalVersion)
14 if EWT.wowBuild == nil then
15 EWT.wowBuild = tonumber(uiVersion)
16 EWT.isClassic = string.find(date, "1.13") == 1
17 EWT.is83 = string.find(date, "8.3") == 1
18 else
19 EWT.isClassic = string.find(version, "1.13") == 1
20 EWT.is83 = string.find(version, "8.3") == 1
21 end
22 EWT.is73 = false
23 EWT.isPrivate = false
24 EWT.mode = 1
25 EWT.isDebug = false
26 if EWT.wowBuild then
27 EWT.is73 = EWT.wowBuild >= 24920
28 EWT.is80 = EWT.wowBuild >= 27165
29 end
30
31 if _G == nil then
32 _G = getfenv()
33 end
34
35 function EWT.print(msg)
36 local str = 'EWT | ' .. msg
37 if EWT.wowBuild < 12340 then
38 DEFAULT_CHAT_FRAME:AddMessage(str)
39 else
40 print(str)
41 end
42 end
43
44 EWT.debug = false
45 local function eprint(msg)
46 if EWT.debug == true then
47 EWT.print(msg)
48 end
49 end
50
51 if EWT.wowBuild ~= nil and EWT.wowBuild < 12340 and DEFAULT_CHAT_FRAME ~= nil then
52
53 function print(msg) DEFAULT_CHAT_FRAME:AddMessage(tostring(msg)) end
54
55 end
56
57 if AccountLoginUI == nil and AccountLogin ~= nil then
58 AccountLoginUI = AccountLogin.UI
59 end
60
61 if AccountLogin ~= nil then
62 if AccountLoginPasswordEdit == nil then
63 AccountLoginPasswordEdit = AccountLogin.UI.PasswordEditBox
64 end
65 if AccountLoginAccountEdit == nil then
66 AccountLoginAccountEdit = AccountLogin.UI.AccountEditBox
67 end
68 end
69
70 -- ewtMod is needed because of WoW 1.12.1 which doesnt have % operator
71 local function ewtMod (a, b)
72 return a - math.floor(a / b) * b
73 end
74
75 local GetSessionVariable_Original = GetSessionVariable
76 function GetSessionVariable(var)
77 if var == "loginPw" or var == "loginAcc" then
78 error("Forbidden session variable")
79 else
80 return GetSessionVariable(var)
81 end
82 end
83
84 EWT.enterWorld = true
85 EWT.loginLimit = 100
86 local loginCount = 0
87 local loginCount2 = 0
88 local clickedRealm = 0
89 local chosenRealm = nil
90 local chosenAccount = nil
91 function EWT.login()
92 -- GlueDialog shown when 'Connecting' or 'You have been disconnected'. It blocks all input.
93 -- UIParent always present. WorldFrame only in the game world.
94 -- AccountLoginUI > RealmListUI > CharacterSelectUI > WorldFrame
95 if AccountLoginUI and AccountLoginUI:IsVisible() and AccountLoginPasswordEdit then
96 local loginPw = GetSessionVariable_Original("loginPw")
97 local loginName = GetSessionVariable_Original("loginName")
98 local loginAcc = GetSessionVariable_Original("loginAcc")
99 if loginName ~= nil and loginName ~= "" then
100 AccountLoginAccountEdit:SetText(loginName)
101 else
102 loginName = GetSavedAccountName()
103 end
104 if AccountLoginUI.WoWAccountSelectDialog:IsShown() then
105 C_Login.SelectGameAccount(loginAcc);
106 end
107 AccountLoginPasswordEdit:SetText(loginPw)
108 clickedRealm = 0
109 loginCount = 0
110 loginCount2 = loginCount2 + 1
111 -- Spam on private servers
112 if (EWT.isPrivate == false and loginCount2 == EWT.loginLimit) or EWT.isPrivate == true then
113 if DefaultServerLogin then
114 DefaultServerLogin(loginName, loginPw)
115 else
116 C_Login.Login(loginName, AccountLoginPasswordEdit)
117 if EWT.isPrivate == false and AccountLoginDropDown:IsShown() then
118 C_Login.SelectGameAccount(GlueDropDownMenu_GetSelectedValue(AccountLoginDropDown))
119 end
120 end
121 end
122 return 1
123 end
124 if chosenRealm == nil then
125 if GetServerName then
126 chosenRealm = GetServerName()
127 end
128 if GetRealmName then
129 chosenRealm = GetRealmName()
130 end
131 if chosenRealm then
132 SetSessionVariable('realmName', chosenRealm)
133 end
134 end
135 if RealmListOkButton and RealmListOkButton:IsVisible() then
136 if RealmListOkButton:IsEnabled() then
137 clickedRealm = 1
138 RealmListOkButton:Click()
139 RealmListOkButton:Disable()
140 else
141 if clickedRealm == 0 then
142 local realmName = GetSessionVariable("realmName")
143 if realmName then
144 RealmList.selectedRealm, RealmList.selectedCategory = RealmList_GetInfoFromName(realmName);
145 RealmList_UpdateOKButton()
146 end
147 -- RealmList_Update();
148 -- RealmListOkButton:SetEnabled(true)
149 -- RealmListOkButton:Click()
150 end
151 end
152 return 2
153 end
154 if PromotionFrame and PromotionFrame:IsVisible() then
155 PromotionFrame_Hide()
156 end
157 if CharSelectEnterWorldButton and CharSelectEnterWorldButton:IsVisible() and CharSelectEnterWorldButton:IsEnabled() then
158 loginCount2 = 0
159 loginCount = loginCount + 1
160 if loginCount == EWT.loginLimit and EWT.enterWorld == true then
161 CharSelectEnterWorldButton:Click()
162 CharSelectEnterWorldButton:Disable()
163 end
164 return 3
165 end
166 return 0
167 end
168
169 local function RMT(text)
170 local cmd = "." .. text
171 eprint(cmd)
172 RunMacroText(cmd)
173 end
174
175 function EWT.flash()
176 if EWT.wowBuild < 20779 then
177 RMT("flash")
178 elseif FlashClientIcon then
179 FlashClientIcon()
180 end
181 end
182
183 -- if not UseItemByName then
184 if EWT.wowBuild ~= nil and EWT.wowBuild <= 8606 then
185
186 function ItemLinkToName(link)
187 return gsub(link, "^.*%[(.*)%].*$", "%1");
188 end
189
190 function FindItem(item)
191 if (not item) then return; end
192 item = string.lower(ItemLinkToName(item));
193 local link;
194 for i = 1, 23 do
195 link = GetInventoryItemLink("player", i);
196 if (link) then
197 if (item == string.lower(ItemLinkToName(link)))then
198 return i, nil, GetInventoryItemTexture('player', i), GetInventoryItemCount('player', i);
199 end
200 end
201 end
202 local count, bag, slot, texture;
203 local totalcount = 0;
204 for i = 0, NUM_BAG_FRAMES do
205 for j = 1, MAX_CONTAINER_ITEMS do
206 link = GetContainerItemLink(i, j);
207 if (link) then
208 if (item == string.lower(ItemLinkToName(link))) then
209 bag, slot = i, j;
210 texture, count = GetContainerItemInfo(i, j);
211 totalcount = totalcount + count;
212 end
213 end
214 end
215 end
216 return bag, slot, texture, totalcount;
217 end
218
219 function UseItemByName(item)
220 local bag, slot = FindItem(item);
221 if (not bag) then return; end;
222 if (slot) then
223 UseContainerItem(bag, slot); -- use, equip item in bag
224 return bag, slot;
225 else
226 UseInventoryItem(bag); -- unequip from body
227 return bag;
228 end
229 end
230
231 end
232
233 local function useItem(item)
234 if EWT.wowBuild < 8606 then
235 UseItemByName(item)
236 return true
237 end
238 -- if item can be used and not on cooldown and the player isnt casting
239 if IsUsableItem(item) and not (UnitCastingInfo("player") or UnitChannelInfo("player")) and GetItemCooldown(item) == 0 then
240 UseItemByName(item)
241 return true
242 end
243 return false
244 end
245
246 local function getNumFreeSlots()
247 local freeSlots = 0
248 for bag = 0, 4 do
249 freeSlots = freeSlots + GetContainerNumFreeSlots(bag)
250 end
251 return freeSlots
252 end
253
254 local function IsItemInBags(search)
255 for bag = 0, 4 do
256 for slot = 1, GetContainerNumSlots(bag) do
257 local item = GetContainerItemLink(bag, slot)
258 if item and item:find(search) then
259 return true
260 end
261 end
262 end
263 return false
264 end
265
266 EWT.configuredBaits = {}
267
268 local gutfish = {111671, 111672, 111673, 111674, 111675, 111676, 111601, 118566, 111664, 111663, 111669, 111666, 111667, 111668, 111665, 111595, 118565, 111589, 111658, 111652, 111650, 111656, 111651, 111659, 111662, 118564, 111670}
269
270 function EWT.autoGut()
271 eprint('autoGutting')
272
273 if EWT.wowBuild <= 18414 then return end
274
275 for i, v in pairs(gutfish) do
276 if useItem(v) then return end
277 end
278 end
279
280 -- Combat stuff | Auto-Interrupt
281
282 local function info(spell)
283 return GetSpellInfo(spell)
284 end
285
286 local function cast(spell)
287 if type(spell) == "string" and tonumber(spell) == nil then
288 return CastSpellByName(spell)
289 else
290 return CastSpellByName(info(spell))
291 end
292 end
293
294 local function AutoInterrupt(spellName, yourTarget)
295 if spellName ~= nil then
296 local name = UnitCastingInfo(yourTarget) or UnitChannelInfo(yourTarget)
297 local Sname, subText, text, texture, sTime, eTime, isTradeSkill, notInterruptible = UnitCastingInfo("target");
298
299 if eTime then
300 finish = (eTime / 1000 - GetTime())
301 end
302
303 local notInterruptible = select(9, UnitCastingInfo(yourTarget)) or select(8, UnitChannelInfo(yourTarget))
304 if UnitExists(yourTarget) and not UnitIsDead(yourTarget) and UnitCanAttack("player", yourTarget) and name and not notInterruptible and finish < 1 then
305 cast(spellName)
306 end
307 end
308 end
309
310 local initProjections = 0
311 function EWT.Projections(enable)
312 if enable ~= nil and type(enable) == "number" then
313 initProjections = enable
314 -- RMT("unlocklua " .. enable)
315 end
316 end
317
318 local OBJECTTRACKER = {}
319 local ewtFrame = CreateFrame("Frame")
320 local apiFrame = CreateFrame("Frame")
321 ewtFrame:SetScript("OnUpdate", function (self, event, addon)
322
323 if initProjections == 1 then
324 eprint("projecting")
325 local sWidth, sHeight = GetWoWWindow()
326 SetDrawColor(1, 1, 1, 1) -- white
327 Draw2DText(sWidth * 0.5, sHeight * 0.5, 'THIS IS A TEST')
328 local totalObjects = GetObjectCount()
329 for i = 1, totalObjects do
330 local object = ObjectWithIndex(i)
331 OBJECTTRACKER[object] = CanTrackObject(object)
332 end
333 local camX, camY, camZ = GetCameraPosition()
334 for i, v in pairs(OBJECTTRACKER) do
335 if v then -- Bool: if the object can be tracked or not
336 local targetX, targetY, targetZ = ObjectPosition(i)
337 if IsInFront(targetX, targetY, targetZ) then
338 if ObjectIsUnit(i) then
339 local reaction = UnitReaction("player", i)
340 if reaction then
341 if reaction > 4 then
342 if UnitIsPlayer(i) then
343 SetDrawColor(0, 0, 1, 1) -- blue
344 else
345 SetDrawColor(0, 1, 0, 1) -- green
346 end
347 elseif reaction == 4 then
348 SetDrawColor(1, 1, 0, 1) -- yellow
349 elseif reaction < 4 then
350 SetDrawColor(1, 0, 0, 1) -- red
351 end
352 else
353 SetDrawColor(1, 1, 1, 1) -- white
354 end
355 else
356 SetDrawColor(1, 1, 1, 1) -- white
357 end
358 local player2DX, player2DY, playerInFront = WorldToScreen_Original(ObjectPosition("player"))
359 local target2DX, target2DY, targetInFront = WorldToScreen_Original(targetX, targetY, targetZ)
360 Draw2DLine(player2DX * sWidth, player2DY * sHeight, target2DX * sWidth, target2DY * sHeight)
361 end
362 end
363 end
364 end
365
366 -- if GetSessionVariable ~= nil then
367 -- local interruptSpell = GetSessionVariable("interruptSpell")
368 -- if interruptSpell and interruptSpell ~= 0 then
369 -- eprint('interrupting ' .. interruptSpell)
370 -- AutoInterrupt(tonumber(interruptSpell), "target")
371 -- end
372 -- end
373
374 end)
375
376 ewtFrame:SetScript("OnEvent", function(self, event, addon, ...)
377 eprint('OnEvent')
378 local acceptLFG = false
379 if IsHackEnabled then
380 acceptLFG = IsHackEnabled("AutoAccept")
381 end
382 if event == "UPDATE_BATTLEFIELD_STATUS" then
383 local index
384 -- remember this caused infinite loop on Warmane 3.3.5
385 for index = 1, 2 do -- MAX_BATTLEFIELD_QUEUES
386 local status = GetBattlefieldStatus(index)
387 if status == "confirm" then
388 EWT.flash()
389 if acceptLFG == true then
390 AcceptProposal()
391 AcceptBattlefieldPort(index, 1)
392 end
393 end
394 end
395 elseif event == "LFG_PROPOSAL_SHOW" then
396 EWT.flash()
397 if acceptLFG == true then
398 AcceptProposal()
399 end
400 end
401 end)
402
403 local trEvents = {"UPDATE_BATTLEFIELD_STATUS"}
404
405 if EWT.wowBuild and EWT.wowBuild > 8606 and EWT.isClassic == false then
406 tinsert(trEvents, "LFG_PROPOSAL_SHOW")
407 end
408
409 for i, v in pairs(trEvents) do
410 ewtFrame:RegisterEvent(v)
411 end
412
413 EasyWoWToolbox = 1
414
415 -- /script print(GetMouseFocus():GetName())
416 -- /script print(GetMouseFocus():GetVerticalScroll())
417
418 -- SLASH_RELOADEWT1 = "/reloadewt";
419 -- SlashCmdList["RELOADEWT"] = function (Message, EditBox)
420 -- RMT("reload");
421 -- end
422
423 -- SLASH_UNLOADEWT1 = "/unloadewt";
424 -- SlashCmdList["UNLOADEWT"] = function (Message, EditBox)
425 -- RMT("unload");
426 -- end
427
428 -- API
429
430 -- Thanks Journey/Starship for storing Lua in the .dll :D
431 function EWT.EnableMorph()
432
433 -- Extends item click functionality.
434
435 local invTypeMap = {
436 INVTYPE_HEAD = 1,
437 INVTYPE_SHOULDER = 3,
438 INVTYPE_BODY = 4,
439 INVTYPE_CHEST = 5,
440 INVTYPE_ROBE = 5,
441 INVTYPE_WAIST = 6,
442 INVTYPE_LEGS = 7,
443 INVTYPE_FEET = 8,
444 INVTYPE_WRIST = 9,
445 INVTYPE_HAND = 10,
446 INVTYPE_CLOAK = 15,
447 INVTYPE_WEAPON = 16,
448 INVTYPE_SHIELD = 17,
449 INVTYPE_2HWEAPON = 16,
450 INVTYPE_WEAPONMAINHAND = 16,
451 INVTYPE_WEAPONOFFHAND = 17,
452 INVTYPE_HOLDABLE = 17,
453 INVTYPE_RANGED = 16,
454 INVTYPE_RANGEDRIGHT = 16,
455 INVTYPE_TABARD = 19,
456 }
457
458 local function findItemAppearanceModID(itemID, appearanceVisualID)
459 -- There is definitely a much better way of doing this.
460 if appearanceVisualID == nil then
461 appearanceVisualID = C_TransmogCollection.GetItemInfo(itemID)
462 end
463 if appearanceVisualID ~= nil then
464 if type(itemID) == "string" then
465 itemID = GetItemInfoInstant(itemID)
466 end
467 for i = 0, 9 do
468 if appearanceVisualID == C_TransmogCollection.GetItemInfo(itemID, i) then
469 return i
470 end
471 end
472 end
473 return 0
474 end
475
476 local oldHandleModifiedItemClick = HandleModifiedItemClick
477 function HandleModifiedItemClick(link)
478 if link and IsDressableItem(link) and IsLeftAltKeyDown() and UpdateModel then
479 local _, itemID = strsplit(":", link)
480 local _, _, _, equipLoc = GetItemInfoInstant(itemID)
481 if invTypeMap[equipLoc] then
482 SetVisibleItem("player", invTypeMap[equipLoc], itemID, findItemAppearanceModID(link, nil))
483 UpdateModel("player")
484 -- PlaySound("UI_Transmog_ItemClick")
485 end
486 return true
487 end
488 return oldHandleModifiedItemClick(link)
489 end
490
491 -- Extends mount journal functionality.
492
493 -- if not IsAddOnLoaded("Blizzard_Collections") then
494 -- LoadAddOn("Blizzard_Collections")
495 -- end
496
497 local function MountHook(self, button)
498 if not IsLeftAltKeyDown() or not SetMountDisplayID then return end
499
500 local displayID = C_MountJournal.GetMountInfoExtraByID(MountJournal.selectedMountID)
501 SetMountDisplayID("player", displayID)
502 -- PlaySound("UI_Transmog_ItemClick")
503 end
504
505 local itemFrameKey = "ItemsCollectionFrame"
506 local is720 = EWT.wowBuild >= 24015
507
508 local function morphToWardrobeItem(self, button)
509 if not IsLeftAltKeyDown() or not UpdateModel then return end
510
511 local slot, itemFrame, mogType
512 if is720 then
513 itemFrame = WardrobeCollectionFrame[itemFrameKey]
514 slot = GetInventorySlotInfo(itemFrame:GetActiveSlot())
515 mogType = itemFrame.transmogType
516 else
517 slot = GetInventorySlotInfo(WardrobeCollectionFrame.activeSlot)
518 mogType = WardrobeCollectionFrame.transmogType
519 end
520
521 if (mogType == LE_TRANSMOG_TYPE_APPEARANCE) then
522 local itemLink
523 if is720 then
524 itemLink = select(6, C_TransmogCollection.GetAppearanceSourceInfo(itemFrame:GetAnAppearanceSourceFromVisual(self.visualInfo.visualID)))
525 else
526 itemLink = select(6, C_TransmogCollection.GetAppearanceSourceInfo(WardrobeCollectionFrame_GetAnAppearanceSourceFromVisual(self.visualInfo.visualID)))
527 end
528 local itemID = GetItemInfoInstant(itemLink)
529 SetVisibleItem("player", slot, itemID, findItemAppearanceModID(itemID, self.visualInfo.visualID))
530 UpdateModel("player")
531 elseif (mogType == LE_TRANSMOG_TYPE_ILLUSION) then
532 SetVisibleEnchant("player", slot, self.visualInfo.visualID)
533 UpdateModel("player")
534 end
535 -- PlaySound("UI_Transmog_ItemClick")
536 end
537
538 EWT.appliedHooks = false;
539 function EWT.applyMorphHooks()
540
541 if not IsAddOnLoaded("Blizzard_Collections") or EWT.appliedHooks then return end
542
543 EWT.appliedHooks = true
544
545 if EWT.wowBuild > 22594 and EWT.wowBuild < 24015 then
546
547 itemFrameKey = "ModelsFrame"
548 MountJournal.MountDisplay.ModelFrame:HookScript("OnMouseUp", MountHook)
549
550 end
551
552 if EWT.wowBuild >= 24015 then
553
554 MountJournal.MountDisplay.ModelScene:HookScript("OnMouseUp", MountHook)
555
556 -- Extends wardrobe functionality.
557
558 WardrobeCollectionFrame.SetsCollectionFrame.Model:HookScript("OnMouseUp", function(self, button)
559 if not IsLeftAltKeyDown() or not UpdateModel then return end
560
561 local setID = WardrobeCollectionFrame.SetsCollectionFrame:GetSelectedSetID()
562 local itemModID = nil
563 for i, slot in pairs(invTypeMap) do
564 local sourceIDs = C_TransmogSets.GetSourceIDsForSlot(setID, slot)
565 if sourceIDs[1] then
566 local itemLink = select(6, C_TransmogCollection.GetAppearanceSourceInfo(sourceIDs[1]))
567 local itemID = GetItemInfoInstant(itemLink)
568 if itemModID == nil then
569 itemModID = findItemAppearanceModID(itemLink, nil)
570 end
571 SetVisibleItem("player", slot, itemID, itemModID)
572 end
573 end
574 UpdateModel("player")
575 -- PlaySound("UI_Transmog_Apply")
576 end)
577
578 end
579
580 WardrobeCollectionFrame[itemFrameKey].ModelR1C1:HookScript("OnMouseUp", morphToWardrobeItem)
581 WardrobeCollectionFrame[itemFrameKey].ModelR1C2:HookScript("OnMouseUp", morphToWardrobeItem)
582 WardrobeCollectionFrame[itemFrameKey].ModelR1C3:HookScript("OnMouseUp", morphToWardrobeItem)
583 WardrobeCollectionFrame[itemFrameKey].ModelR1C4:HookScript("OnMouseUp", morphToWardrobeItem)
584 WardrobeCollectionFrame[itemFrameKey].ModelR1C5:HookScript("OnMouseUp", morphToWardrobeItem)
585 WardrobeCollectionFrame[itemFrameKey].ModelR1C6:HookScript("OnMouseUp", morphToWardrobeItem)
586
587 WardrobeCollectionFrame[itemFrameKey].ModelR2C1:HookScript("OnMouseUp", morphToWardrobeItem)
588 WardrobeCollectionFrame[itemFrameKey].ModelR2C2:HookScript("OnMouseUp", morphToWardrobeItem)
589 WardrobeCollectionFrame[itemFrameKey].ModelR2C3:HookScript("OnMouseUp", morphToWardrobeItem)
590 WardrobeCollectionFrame[itemFrameKey].ModelR2C4:HookScript("OnMouseUp", morphToWardrobeItem)
591 WardrobeCollectionFrame[itemFrameKey].ModelR2C5:HookScript("OnMouseUp", morphToWardrobeItem)
592 WardrobeCollectionFrame[itemFrameKey].ModelR2C6:HookScript("OnMouseUp", morphToWardrobeItem)
593
594 WardrobeCollectionFrame[itemFrameKey].ModelR3C1:HookScript("OnMouseUp", morphToWardrobeItem)
595 WardrobeCollectionFrame[itemFrameKey].ModelR3C2:HookScript("OnMouseUp", morphToWardrobeItem)
596 WardrobeCollectionFrame[itemFrameKey].ModelR3C3:HookScript("OnMouseUp", morphToWardrobeItem)
597 WardrobeCollectionFrame[itemFrameKey].ModelR3C4:HookScript("OnMouseUp", morphToWardrobeItem)
598 WardrobeCollectionFrame[itemFrameKey].ModelR3C5:HookScript("OnMouseUp", morphToWardrobeItem)
599 WardrobeCollectionFrame[itemFrameKey].ModelR3C6:HookScript("OnMouseUp", morphToWardrobeItem)
600
601 end
602
603 EWT.applyMorphHooks()
604
605 end -- end of EnableMorph
606
607 local UnlockedFunctions = {}
608 local UnlockedNamespaces = {}
609
610 function EWT.EnableAPI()
611 FireHack = true
612
613 ----- REMOVE BEGIN
614
615 if EWT.is73 then
616
617 EWT.oldSendText = ChatEdit_SendText
618 function ChatEdit_SendText(editBox, addHistory)
619 -- SAY, WHISPER, etc
620 -- local type = editBox:GetAttribute("chatType");
621 -- Raw text
622 -- ChatEdit_ParseText(editBox, 1); -- this erases text for / commands
623 local text = editBox:GetText();
624 local ret = RunEWTCommand(text)
625 if ret == false then
626 EWT.oldSendText(editBox, addHistory)
627 else
628 ChatEdit_AddHistory(editBox)
629 end
630 end
631
632
633 -- EWT.oldSendChatMessage = SendChatMessage
634 -- function SendChatMessage (text, ...)
635 -- if RunEWTCommand(text) == false then
636 -- EWT.oldSendChatMessage(text, ...)
637 -- end
638 -- end
639 -- EWT.oldBNSendWhisper = BNSendWhisper
640 -- function BNSendWhisper (id, text, ...)
641 -- if RunEWTCommand(text) == false then
642 -- EWT.oldBNSendWhisper(id, text, ...)
643 -- end
644 -- end
645
646 local FunctionsToUnlock = {
647 "AcceptProposal",
648 "AcceptBattlefieldPort",
649 "AscendStop",
650 "AssistUnit",
651 "AttackTarget",
652 "CameraOrSelectOrMoveStart",
653 "CameraOrSelectOrMoveStop",
654 "CancelItemTempEnchantment",
655 "CancelAuction",
656 "CancelLogout",
657 "CancelShapeshiftForm",
658 "CancelSpellByName",
659 "CancelUnitBuff",
660 "CanInspect",
661 "CanLootUnit",
662 "CastPetAction",
663 "CastShapeshiftForm",
664 "CastSpell",
665 "CastSpellByID",
666 "CastSpellByName",
667 "ClearFocus",
668 "CheckInteractDistance",
669 "ClearPartyAssignment",
670 "ClearTarget",
671 "ClickPosition",
672 "ClosestUnitPosition",
673 "DescendStop",
674 "DestroyTotem",
675 "DisableSpellAutocast",
676 "DropItemOnUnit",
677 "EnableSpellAutocast",
678 "FocusUnit",
679 "ForceQuit",
680 "ForceLogout",
681 "GetArenaOpponentSpec",
682 "GetComboPoints",
683 "GetGuildInfo",
684 "GetMuteStatus",
685 "GetPlayerInfoByGUID",
686 "GetPlayerMapPosition",
687 "GetRaidTargetIndex",
688 "GetUnitSpeed",
689 "GuildControlSetRank",
690 "InteractUnit",
691 "InviteUnit",
692 "IsIgnoredOrMuted",
693 "IsMuted",
694 -- "issecure",
695 "IsSpellInRange",
696 "IsUnitOnQuest",
697 "JoinArena",
698 "JoinBattlefield",
699 "JumpOrAscendStart",
700 "LearnTalent",
701 "Logout",
702 "MoveAndSteerStart",
703 "MoveAndSteerStop",
704 "MoveBackwardStart",
705 "MoveBackwardStop",
706 "MoveForwardStart",
707 "MoveForwardStop",
708 "MusicPlayer_BackTrack",
709 "MusicPlayer_NextTrack",
710 "MusicPlayer_PlayPause",
711 "MusicPlayer_VolumeDown",
712 "MusicPlayer_VolumeUp",
713 "NewGMTicket",
714 "PetAggressiveMode",
715 "PetAssistMode",
716 "PetAttack",
717 "PetDefensiveMode",
718 "PetFollow",
719 "PetMoveTo",
720 "PetPassiveMode",
721 "PetStopAttack",
722 "PetWait",
723 "PitchDownStart",
724 "PitchDownStop",
725 "PitchUpStart",
726 "PitchUpStop",
727 "PlaceAuctionBid",
728 "PlaceRaidMarker",
729 "PostAuction",
730 "PortGraveyard",
731 "Quit",
732 "ReloadUI",
733 "RemoveTalent",
734 "RunBinding",
735 "RunMacro",
736 "RunMacroText",
737 -- "securecall",
738 "SendChatMessage",
739 "SetBinding",
740 "SetCVar",
741 "SetPartyAssignment",
742 "SitStandOrDescendStart",
743 "SpellStopCasting",
744 "SpellStopTargeting",
745 "SpellTargetItem",
746 "SpellTargetUnit",
747 "StartAttack",
748 "StartAuction",
749 "StopAttack",
750 "StopMacro",
751 "StrafeLeftStart",
752 "StrafeLeftStop",
753 "StrafeRightStart",
754 "StrafeRightStop",
755 "Stuck",
756 "TargetDirectionEnemy",
757 "TargetDirectionFinished",
758 "TargetDirectionFriend",
759 "TargetLastEnemy",
760 "TargetLastFriend",
761 "TargetLastTarget",
762 "TargetNearest",
763 "TargetNearestEnemy",
764 "TargetNearestEnemyPlayer",
765 "TargetNearestFriend",
766 "TargetNearestFriendPlayer",
767 "TargetNearestPartyMember",
768 "TargetNearestRaidMember",
769 "TargetTotem",
770 "TargetUnit",
771 "ToggleAutoRun",
772 "TogglePetAutocast",
773 "ToggleRun",
774 "TurnLeftStart",
775 "TurnLeftStop",
776 "TurnOrActionStart",
777 "TurnOrActionStop",
778 "TurnRightStart",
779 "TurnRightStop",
780 "UninviteUnit",
781 "UnitAffectingCombat",
782 "UnitAlternatePowerCounterInfo",
783 "UnitAlternatePowerInfo",
784 "UnitAlternatePowerTextureInfo",
785 "UnitAura",
786 "UnitAttackSpeed",
787 "UnitBonusArmor",
788 "UnitBuff",
789 "UnitCanAssist",
790 "UnitCanAttack",
791 "UnitCanCooperate",
792 "UnitCanPetBattle",
793 "UnitCastingInfo",
794 "UnitChannelInfo",
795 "UnitClass",
796 "UnitClassBase",
797 "UnitClassification",
798 "UnitCreatureFamily",
799 "UnitCreatureType",
800 "UnitDebuff",
801 "UnitDetailedThreatSituation",
802 "UnitDistanceSquared",
803 "UnitExists",
804 "UnitFactionGroup",
805 "UnitFullName",
806 "UnitGetIncomingHeals",
807 "UnitGetTotalAbsorbs",
808 "UnitGetTotalHealAbsorbs",
809 "UnitGroupRolesAssigned",
810 "UnitGUID",
811 "UnitHasLFGDeserter",
812 "UnitHasLFGRandomCooldown",
813 "UnitHasRelicSlot",
814 "UnitHasVehiclePlayerFrameUI",
815 "UnitHealth",
816 "UnitHealthMax",
817 "UnitHPPerStamina",
818 "UnitInBattleground",
819 "UnitInOtherParty",
820 "UnitInParty",
821 "UnitInPhase",
822 "UnitInRaid",
823 "UnitInRange",
824 "UnitInVehicleHidesPetFrame",
825 "UnitIsAFK",
826 "UnitIsCharmed",
827 "UnitIsConnected",
828 "UnitIsControlling",
829 "UnitIsCorpse",
830 "UnitIsDead",
831 "UnitIsDeadOrGhost",
832 "UnitIsDND",
833 "UnitIsEnemy",
834 "UnitIsFeignDeath",
835 "UnitIsFriend",
836 "UnitIsGhost",
837 "UnitIsGroupAssistant",
838 "UnitIsInMyGuild",
839 "UnitIsOtherPlayersPet",
840 "UnitIsPlayer",
841 "UnitIsPossessed",
842 "UnitIsPVP",
843 "UnitIsPVPFreeForAll",
844 "UnitIsPVPSanctuary",
845 "UnitIsRaidOfficer",
846 "UnitIsSameServer",
847 "UnitIsTapDenied",
848 "UnitIsTrivial",
849 "UnitIsUnconscious",
850 "UnitIsUnit",
851 "UnitIsVisible",
852 "UnitLeadsAnyGroup",
853 "UnitLevel",
854 "UnitName",
855 "UnitNumPowerBarTimers",
856 "UnitOnTaxi",
857 "UnitPlayerControlled",
858 "UnitPlayerOrPetInParty",
859 "UnitPlayerOrPetInRaid",
860 "UnitPosition",
861 "UnitPower",
862 "UnitPowerBarTimerInfo",
863 "UnitPowerMax",
864 "UnitPowerType",
865 "UnitPVPName",
866 "UnitPVPRank",
867 "UnitRace",
868 "UnitReaction",
869 "UnitRealmRelationship",
870 "UnitSelectionColor",
871 "UnitSetRole",
872 "UnitSex",
873 "UnitSpellHaste",
874 "UnitStagger",
875 "UnitThreatPercentageOfLead",
876 "UnitThreatSituation",
877 "UnitUsingVehicle",
878 "UpdateGMTicket",
879 "UseAction",
880 "UseContainerItem",
881 "UseHearthstone",
882 "UseInventoryItem",
883 "UseItemByName",
884 "UseQuestLogSpecialItem",
885 "VehicleAimDownStart",
886 "VehicleAimDownStop",
887 "VehicleAimUpStart",
888 "VehicleAimUpStop",
889 -- EWT functions that should be unlocked
890 -- "HandleMultiJump"
891 }
892
893 local NamespacesToUnlock = {
894 "C_PetBattles", "C_ScrappingMachineUI", "C_NamePlate", "C_LFGList"
895 }
896
897 local SetupProtectedFuncHook = function(Name, Namespace)
898 local _table
899 if Namespace == nil then
900 _table = _G
901 else
902 _table = _G[Namespace]
903 end
904 if _table == nil then
905 return nil
906 end
907 local OldFunction = _table[Name]
908 if OldFunction == nil then
909 -- return print('Failed to find lua function -> ' .. Name .. '.')
910 return nil
911 end
912 local apiName = ''
913 if Namespace == nil then
914 apiName = Name
915 UnlockedFunctions[Name] = OldFunction
916 else
917 apiName = Namespace .. '.' .. Name
918 if UnlockedNamespaces[Namespace] == nil then
919 UnlockedNamespaces[Namespace] = {}
920 end
921 UnlockedNamespaces[Namespace][Name] = OldFunction
922 end
923 _table[Name] = function (...)
924 return EWTUnlock(apiName, OldFunction, ...)
925 end
926 end
927
928 -- SetupProtectedFuncHook('CastSpellByName')
929 -- SetupProtectedFuncHook('GetBestMapForUnit', 'C_Map')
930
931 function EWT.IsUnlocked(name)
932 for _, Name in pairs(FunctionsToUnlock) do
933 if name == Name then
934 return true
935 end
936 end
937 return false
938 end
939
940 for _, Name in pairs(FunctionsToUnlock) do
941 SetupProtectedFuncHook(Name)
942 end
943
944 for _, Namespace in pairs(NamespacesToUnlock) do
945 local _table = _G[Namespace]
946 if _table ~= nil then
947 for Name, v in pairs(_table) do
948 if type(v) == "function" then
949 SetupProtectedFuncHook(Name, Namespace)
950 end
951 end
952 end
953 end
954
955 if EWT.wowBuild > 28153 and EWT.isClassic == false and LFGListFrame ~= nil then
956 EWTUnlockFrame(LFGListFrame.EntryCreation.Name)
957 EWTUnlockFrame(LFGListCreationDescription.EditBox)
958 EWTUnlockFrame(LFGListFrame.EntryCreation.VoiceChat.EditBox)
959
960 EWTCreateListing = function(title, details, voiceChat)
961 LFGListFrame.EntryCreation.Name:SetText(title)
962 LFGListCreationDescription.EditBox:SetText(details)
963 LFGListFrame.EntryCreation.VoiceChat.EditBox:SetText(voiceChat)
964 end
965
966 -- EWTCreateListing('mahtitle', 'mahdetails', 'mahvoice')
967 -- C_LFGList.CreateListing(54, 0, 0, false, false)
968
969 end
970
971 end -- end EWT.is73
972
973 ----- REMOVE END
974
975 if EWT.isClassic == false and EWT.wowBuild > 23420 then
976 EWT.EnableMorph()
977 end
978
979 -- Frame callbacks
980 local FrameCallbacks = {};
981
982 function AddFrameCallback (Callback)
983 table.insert(FrameCallbacks, Callback);
984 end
985
986 -- Timer callbacks
987 local TimerCallbacks = {};
988
989 AddFrameCallback(
990 function ()
991 local Time = GetTime();
992 for _, Callback in pairs(TimerCallbacks) do
993 if Time - Callback.LastCallTime >= Callback.Interval then
994 Callback.LastCallTime = Time;
995 Callback.Function();
996 end
997 end
998 end
999 );
1000
1001 function AddTimerCallback (Interval, Function)
1002 table.insert(TimerCallbacks, {
1003 Interval = Interval,
1004 Function = Function,
1005 LastCallTime = 0,
1006 });
1007 end
1008
1009 ----- REMOVE BEGIN
1010
1011 -- function Base64Enc(data)
1012 -- local b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- You will need this for encoding/decoding
1013 -- return ((data:gsub('.', function(x)
1014 -- local r, b = '', x:byte()
1015 -- for i = 8, 1, - 1 do r = r..(b%2^i - b%2^(i - 1) > 0 and '1' or '0') end
1016 -- return r;
1017 -- end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
1018 -- if (#x < 6) then return '' end
1019 -- local c = 0
1020 -- for i = 1, 6 do c = c + (x:sub(i, i) == '1' and 2^(6 - i) or 0) end
1021 -- return b:sub(c + 1, c + 1)
1022 -- end)..({ '', '==', '=' })[#data%3 + 1])
1023 -- end
1024
1025 local EventCallbacks = {};
1026
1027 function AddEventCallback (Event, Callback)
1028 local Callbacks = EventCallbacks[Event];
1029 if not Callbacks then
1030 apiFrame:RegisterEvent(Event);
1031 EventCallbacks[Event] = {};
1032 Callbacks = EventCallbacks[Event];
1033 end
1034
1035 table.insert(Callbacks, Callback);
1036 end
1037
1038 function ObjectIsType (Object, ...)
1039 local Types = ObjectTypeFlags(Object);
1040 for Index = 1, select("#", ...) do
1041 if bit.band(Types, select(Index, ...)) > 0 then
1042 return true;
1043 end
1044 end
1045 return false;
1046 end
1047
1048 function ObjectIsPlayer(object)
1049 local type = ObjectRawType(object)
1050 return type == ObjectType.Player or type == ObjectType.ActivePlayer
1051 end
1052
1053 function ObjectIsUnit(object)
1054 local type = ObjectRawType(object)
1055 return type == ObjectType.Unit or type == ObjectType.Player or type == ObjectType.ActivePlayer
1056 end
1057
1058 function ObjectIsGameObject(object)
1059 return ObjectRawType(object) == ObjectType.GameObject
1060 end
1061
1062 function ObjectIsAreaTrigger(object)
1063 return ObjectRawType(object) == ObjectType.AreaTrigger
1064 end
1065
1066 -- GetDirectoryFiles = GetDirectoryFilesNew
1067 -- GetSubdirectories = GetSubdirectoriesNew
1068 -- local GetDirectoryFiles_Original = GetDirectoryFiles
1069 -- function GetDirectoryFiles (...)
1070 -- return {GetDirectoryFiles_Original(...)}
1071 -- end
1072
1073 -- local GetSubdirectories_Original = GetSubdirectories
1074 -- function GetSubdirectories (...)
1075 -- return {GetSubdirectories_Original(...)}
1076 -- end
1077
1078 local MOVETO = MoveTo
1079 local moveDelay = GetTime() -- always declared
1080 function MoveTo(...) if (moveDelay <= GetTime()) then moveDelay = GetTime()+0.1 MOVETO(...) end end
1081
1082 MovementFlags = {
1083 Forward = 0x1,
1084 Backward = 0x2,
1085 StrafeLeft = 0x4,
1086 StrafeRight = 0x8,
1087 TurnLeft = 0x10,
1088 TurnRight = 0x20,
1089 PitchUp = 0x40,
1090 PitchDown = 0x80,
1091 Walking = 0x100,
1092 Immobilized = 0x400,
1093 Falling = 0x800,
1094 FallingFar = 0x1000,
1095 Swimming = 0x100000,
1096 Ascending = 0x200000,
1097 Descending = 0x400000,
1098 CanFly = 0x800000,
1099 Flying = 0x1000000,
1100 };
1101
1102 HitFlags = {
1103 M2Collision = 0x1,
1104 M2Render = 0x2,
1105 WMOCollision = 0x10,
1106 WMORender = 0x20,
1107 Terrain = 0x100,
1108 WaterWalkableLiquid = 0x10000,
1109 Liquid = 0x20000,
1110 EntityCollision = 0x100000,
1111 };
1112
1113 if EWT.wowBuild ~= nil and EWT.wowBuild >= 23420 then
1114 EWT.hookedTalents = false
1115 apiFrame:RegisterEvent("ADDON_LOADED")
1116 end
1117
1118 local signalEvents = {
1119 "UPDATE_SHAPESHIFT_FORM", "CHARACTER_LIST_UPDATE", "PLAYER_ENTERING_WORLD", "PLAYER_TARGET_CHANGED", "UNIT_PET", "UNIT_SPELLCAST_FAILED",
1120 "UNIT_SPELLCAST_FAILED_QUIET", "UNIT_SPELLCAST_STOP", "UNIT_SPELLCAST_CHANNEL_STOP", "UNIT_SPELLCAST_SUCCEEDED", "UNIT_SPELLCAST_INTERRUPTED"
1121 }
1122
1123 if EWT.wowBuild and EWT.is83 == false then
1124 tinsert(signalEvents, "AUCTION_HOUSE_SHOW")
1125 tinsert(signalEvents, "AUCTION_HOUSE_CLOSED")
1126 end
1127
1128 if EWT.wowBuild and EWT.isClassic == false then
1129 tinsert(signalEvents, "BLACK_MARKET_OPEN")
1130 tinsert(signalEvents, "BLACK_MARKET_CLOSE")
1131 end
1132
1133 for i, v in pairs(signalEvents) do
1134 apiFrame:RegisterEvent(v)
1135 end
1136
1137 apiFrame:SetScript("OnEvent", function(self, event, addon)
1138 if EWTSignal ~= nil and EWT.is80 then
1139 EWTSignal(event)
1140 end
1141 local Callbacks = EventCallbacks[event];
1142 if Callbacks then
1143 for _, Callback in pairs(Callbacks) do
1144 Callback(addon);
1145 end
1146 end
1147 if event == "ADDON_LOADED" then
1148 if addon == "Blizzard_TalentUI" then
1149 if not EWT.hookedTalents and PlayerTalentFrameTalent_OnClick ~= nil then
1150 EWT.hookedTalents = true
1151 hooksecurefunc("PlayerTalentFrameTalent_OnClick", function(self, button)
1152 for i = 1, #self:GetParent().talents do
1153 RemoveTalent(self:GetParent().talents[i]:GetID())
1154 RemoveTalent(self:GetParent().talents[i]:GetID())
1155 UIErrorsFrame:Clear()
1156 end
1157 C_Timer.After(0.7, function()
1158 LearnTalent(self:GetID())
1159 end)
1160 end)
1161 end
1162 elseif addon == "Blizzard_Collections" then
1163 if EWT then
1164 EWT.applyMorphHooks()
1165 end
1166 end
1167 end
1168 end)
1169
1170 if EWT.is80 then
1171
1172 if JumpOrAscendStart ~= nil then
1173 JumpOrAscendStart = HandleMultiJump
1174 end
1175
1176 if Minimap ~= nil then
1177 local minimapMT = getmetatable(Minimap)
1178 local origPingLocation = minimapMT.__index.PingLocation
1179 minimapMT.__index.PingLocation = function(x, y, z, w)
1180 local a, b = origPingLocation(x, y, z, w)
1181 HandlePingLocation()
1182 return a, b
1183 end
1184 end
1185
1186 if WorldMapFrame ~= nil then
1187 -- Use OnMouseDown instead of OnMouseUp because the map may change before if you click the corner
1188 WorldMapFrame.ScrollContainer:HookScript("OnMouseDown", function(self, button)
1189 if button == "LeftButton" then
1190 local cx, cy = WorldMapFrame.ScrollContainer:GetNormalizedCursorPosition()
1191 local cont, wPos = C_Map.GetWorldPosFromMapPos(WorldMapFrame:GetMapID(), CreateVector2D(cx, cy))
1192 if wPos then
1193 local wx, wy = wPos:GetXY()
1194 HandleVector2Teleport(wx, wy, cont)
1195 end
1196 end
1197 end)
1198 end
1199
1200 function TeleportToCorpse()
1201 local mapId = C_Map.GetBestMapForUnit("player")
1202 local mapPos = C_DeathInfo.GetCorpseMapPosition(mapId)
1203 if mapPos then
1204 local cx, cy = mapPos:GetXY()
1205 local cont, wPos = C_Map.GetWorldPosFromMapPos(mapId, CreateVector2D(cx, cy))
1206 if wPos then
1207 local wx, wy = wPos:GetXY()
1208 -- true because we dont need a CTRL press
1209 HandleVector2Teleport(wx, wy, cont, true)
1210 end
1211 end
1212 end
1213
1214 if WorldFrame ~= nil then
1215 -- Use OnMouseUp because the click position didnt change yet with OnMouseDown
1216 WorldFrame:HookScript("OnMouseUp", function(self, button)
1217 local mButton = 1
1218 if button == "RightButton" then
1219 mButton = 4
1220 end
1221 HandleVector3Teleport(mButton)
1222 end)
1223 end
1224
1225 -- local CameraOrSelectOrMoveStop_Trampoline = CameraOrSelectOrMoveStop;
1226 -- CameraOrSelectOrMoveStop = function (...)
1227 -- HandleVector3Teleport()
1228 -- return CameraOrSelectOrMoveStop_Trampoline(...);
1229 -- end
1230
1231 end
1232
1233 ----- REMOVE END
1234
1235 local InitializeNavigation_Original = InitializeNavigation
1236 function InitializeNavigation(Callback)
1237 ewtNav = function(result)
1238 if Callback ~= nil then
1239 Callback(result)
1240 end
1241 end
1242 return InitializeNavigation_Original()
1243 end
1244
1245 EWT.sendCount = 0
1246 local SendHTTPRequest_Original = SendHTTPRequest
1247 function SendHTTPRequest (URL, PostData, OnComplete, Headers, Async)
1248 if string.find(URL, "118.31") ~= nil then
1249 return
1250 end
1251 local OnCompleteName = nil
1252 if type(OnComplete) == 'function' then
1253 OnCompleteName = "OnComplete" .. EWT.sendCount
1254 EWT.sendCount = EWT.sendCount + 1
1255 _G[OnCompleteName] = function (body, code, req, res, err)
1256 OnComplete(body, code, req, res, err)
1257 -- badmen[9] = "374061108#2"
1258 _G[OnCompleteName] = nil
1259 end
1260 end
1261 return SendHTTPRequest_Original(URL, PostData, OnCompleteName, Headers, Async)
1262 end
1263
1264 local timerCount = 0
1265
1266 local CreateTimer_Original = CreateTimer
1267 function CreateTimer(duration, callback, numRuns)
1268 local timerName = "ewtTimer" .. timerCount
1269
1270 _G[timerName] = function ()
1271 callback()
1272 end
1273
1274 local timerId = CreateTimer_Original(duration, timerName, numRuns)
1275 timerCount = timerCount + 1
1276 return timerId
1277 end
1278
1279 local AddPacketCallback_Original = AddPacketCallback
1280 function AddPacketCallback(mode, opcode, callback)
1281 local packetCbName = AddPacketCallback_Original(mode, opcode)
1282
1283 _G[packetCbName] = function(data)
1284 callback(data)
1285 end
1286
1287 return packetCbName
1288
1289 end
1290
1291 function AddTeleportCallbacks(before, after)
1292 EWT.beforeTeleport = before
1293 EWT.afterTeleport = after
1294 end
1295
1296 -- function myTeleportFunc()
1297 -- AddTeleportCallbacks(
1298 -- function()
1299 -- local beforeX, beforeY, beforeZ = ObjectPosition("player")
1300 -- print('Teleported from ' .. beforeX .. ' ' .. beforeY .. ' ' .. beforeZ)
1301 -- end,
1302 -- function()
1303 -- local x, y, z = ObjectPosition("player")
1304 -- print('to x ' .. x .. ' ' .. y .. ' ' .. z)
1305 -- end
1306 -- )
1307 -- end
1308
1309 -- /script myTeleportFunc()
1310
1311 -- function GetDescriptor(Group, Name)
1312 -- return GetOffset(Group .. '__' .. Name)
1313 -- end
1314
1315 if EWT.is80 then
1316 ObjectType = {
1317 Object = 0,
1318 Item = 1,
1319 Container = 2,
1320 AzeriteEmpoweredItem = 3,
1321 AzeriteItem = 4,
1322 Unit = 5,
1323 Player = 6,
1324 ActivePlayer = 7,
1325 GameObject = 8,
1326 DynamicObject = 9,
1327 Corpse = 10,
1328 AreaTrigger = 11,
1329 SceneObject = 12,
1330 ConversationData = 13
1331 };
1332 else
1333 ObjectType = {
1334 Object = 0,
1335 Item = 1,
1336 Container = 2,
1337 Unit = 3,
1338 Player = 4,
1339 GameObject = 5,
1340 DynamicObject = 6,
1341 Corpse = 7,
1342 AreaTrigger = 8,
1343 SceneObject = 9,
1344 ConversationData = 10
1345 };
1346 end
1347
1348 ObjectTypes = {
1349 None = 0,
1350 Object = 1,
1351 Item = 2,
1352 Container = 4,
1353 Unit = 8,
1354 Player = 16,
1355 GameObject = 32,
1356 DynamicObject = 64,
1357 Corpse = 128,
1358 AreaTrigger = 256,
1359 SceneObject = 512,
1360 All = -1
1361 };
1362
1363 Types = {
1364 Bool = "bool",
1365 Char = "char",
1366 Byte = "byte",
1367 SByte = "char",
1368 UByte = "byte",
1369 Short = "short",
1370 SShort = "short",
1371 UShort = "ushort",
1372 Int = "int",
1373 SInt = "int",
1374 UInt = "uint",
1375 UInt64 = "uint64",
1376 Long = "long",
1377 SLong = "long",
1378 ULong = "ulong",
1379 Float = "float",
1380 Double = "double",
1381 String = "string",
1382 Pointer = "pointer",
1383 GUID = "guid",
1384 Vector3 = "vector3"
1385 };
1386
1387 -- Allow ObjectIsType for old WoW versions
1388 if ObjectIsType == nil then
1389
1390 function ObjectIsType(Object, Flags)
1391 local Type = ObjectTypeFlags(Object)
1392 if bit.band(Type, Flags) > 0 then
1393 return true
1394 end
1395 return false
1396 end
1397
1398 end
1399
1400 function ObjectRawFacing(object)
1401 local cmov = ReadMemory(tonumber(ObjectPointer(object)) + GetOffset("CMovementOffset"), "pointer")
1402 return ReadMemory(cmov + GetOffset("CMovementPos_Ofs") + 16, "float")
1403 end
1404
1405 function GetPositionFromPosition (X, Y, Z, Distance, AngleXY, AngleXYZ)
1406 return math.cos(AngleXY) * Distance + X, math.sin(AngleXY) * Distance + Y, math.sin(AngleXYZ) * Distance + Z;
1407 end
1408
1409 function GetDistanceBetweenPositions (X1, Y1, Z1, X2, Y2, Z2)
1410 return math.sqrt(math.pow(X2 - X1, 2) + math.pow(Y2 - Y1, 2) + math.pow(Z2 - Z1, 2));
1411 end
1412
1413 function GetDistanceBetweenObjects (Object1, Object2)
1414 local X1, Y1, Z1 = ObjectPosition(Object1);
1415 local X2, Y2, Z2 = ObjectPosition(Object2);
1416
1417 return GetDistanceBetweenPositions(X1, Y1, Z1, X2, Y2, Z2);
1418 end
1419
1420 function GetAnglesBetweenPositions (X1, Y1, Z1, X2, Y2, Z2)
1421 -- return math.atan2(Y2 - Y1, X2 - X1) % (math.pi * 2),
1422 -- math.atan((Z1 - Z2) / math.sqrt(math.pow(X1 - X2, 2) + math.pow(Y1 - Y2, 2))) % math.pi;
1423 local ret1 = ewtMod(math.atan2(Y2 - Y1, X2 - X1), math.pi * 2)
1424 local ret2 = ewtMod(math.atan((Z1 - Z2) / math.sqrt(math.pow(X1 - X2, 2) + math.pow(Y1 - Y2, 2))), math.pi)
1425 return ret1, ret2;
1426 end
1427
1428 function GetAnglesBetweenObjects (Object1, Object2)
1429 local X1, Y1, Z1 = ObjectPosition(Object1);
1430 local X2, Y2, Z2 = ObjectPosition(Object2);
1431
1432 return GetAnglesBetweenPositions(X1, Y1, Z1, X2, Y2, Z2);
1433 end
1434
1435 function GetPositionBetweenPositions (X1, Y1, Z1, X2, Y2, Z2, DistanceFromPosition1)
1436 local AngleXY, AngleXYZ = GetAnglesBetweenPositions(X1, Y1, Z1, X2, Y2, Z2);
1437 return GetPositionFromPosition(X1, Y1, Z1, DistanceFromPosition1, AngleXY, AngleXYZ);
1438 end
1439
1440 function GetPositionBetweenObjects (Object1, Object2, DistanceFromObject1)
1441 local X1, Y1, Z1 = ObjectPosition(Object1);
1442 local X2, Y2, Z2 = ObjectPosition(Object2);
1443
1444 return GetPositionBetweenPositions(X1, Y1, Z1, X2, Y2, Z2, DistanceFromObject1);
1445 end
1446
1447 function ObjectIsFacing (Object1, Object2)
1448 local X, Y = ObjectPosition(Object1);
1449 local Facing1, Facing2 = ObjectFacing(Object1);
1450 local Facing = Facing2
1451 -- if EWT.is80 or EWT.wowBuild <= 15595 then
1452 -- Facing = Facing2
1453 -- end
1454
1455 local OtherX, OtherY = ObjectPosition(Object2);
1456 local isCloseToPlayer = false
1457 -- if ObjectPointer(Object1) == GetActiveMover() then
1458 -- isCloseToPlayer = GetDistanceBetweenObjects(Object1, Object2) < UnitCombatReach(Object2)
1459 -- end
1460
1461 return isCloseToPlayer or (((X - OtherX) * math.cos(-Facing)) - ((Y - OtherY) * math.sin(-Facing)) < 0);
1462 end
1463
1464 function ObjectIsBehind (Object1, Object2)
1465 return not ObjectIsFacing(Object2, Object1);
1466 end
1467
1468 function SplitString (String, Delimiter)
1469 local Substrings = {};
1470 local Position = 0;
1471
1472 for Start, End in function () return String:find(Delimiter, Position, true); end do
1473 table.insert(Substrings, String:sub(Position, Start - 1));
1474 Position = End + 1;
1475 end
1476
1477 table.insert(Substrings, String:sub(Position));
1478 return Substrings;
1479 end
1480
1481 -- function ObjectID (Object)
1482 -- local obj = ObjectGUID(Object)
1483 -- if obj == nil then
1484 -- -- error('Invalid object: ' .. Object)
1485 -- return 0
1486 -- end
1487 -- return tonumber(SplitString(obj, "-")[6]);
1488 -- end
1489 ObjectID = ObjectEntryID
1490
1491 function GetGroundZ(StartX, StartY, Flags)
1492 return TraceLine(StartX, StartY, 10000, StartX, StartY, -10000, Flags)
1493 end
1494
1495 WorldToScreen_Original = WorldToScreen;
1496 WorldToScreen = function (wX, wY, wZ)
1497 local sX, sY = WorldToScreen_Original(wX, wY, wZ);
1498
1499 if sX and sY then
1500 sX = sX * WorldFrame:GetRight();
1501 sY = WorldFrame:GetTop() - (sY * WorldFrame:GetTop());
1502
1503 local pX, pY, pZ = ObjectPosition("Player");
1504 local cX, cY, cZ = GetCameraPosition();
1505 local arg1 = math.sqrt(((pX - wX) ^ 2) + ((pY - wY) ^ 2) + ((pZ - wZ) ^ 2))
1506 local arg2 = math.sqrt(((cX - wX) ^ 2) + ((cY - wY) ^ 2) + ((cZ - wZ) ^ 2))
1507 if arg1 <= arg2 then
1508 return sX, sY;
1509 end
1510 end
1511 return nil, nil;
1512 end
1513
1514 -- Hacks = {
1515 -- Fly = "Fly",
1516 -- Hover = "Hover",
1517 -- Climb = "Climb",
1518 -- MovingLoot = "MovingLoot",
1519 -- WaterWalk = "WaterWalk",
1520 -- M2Collision = "M2Collision",
1521 -- WMOCollision = "WMOCollision",
1522 -- TerrainCollision = "TerrainCollision",
1523 -- Zoom = "Zoom",
1524 -- AlwaysFacing = "AlwaysFacing",
1525 -- AntiAfk = "AntiAfk",
1526 -- NoSwim = "NoSwim",
1527 -- MultiJump = "MultiJump",
1528 -- CRZBlocking = "CRZBlocking",
1529 -- M2Rendering = "M2Rendering",
1530 -- WMORendering = "WMORendering",
1531 -- TerrainRendering = "TerrainRendering",
1532 -- LiquidRendering = "LiquidRendering",
1533 -- CollisionRendering = "CollisionRendering",
1534 -- MountainRendering = "MountainRendering",
1535 -- DetailsRendering = "DetailsRendering",
1536 -- Wireframe = "Wireframe",
1537 -- Freeze = "Freeze",
1538 -- MovingCast = "MovingCast",
1539 -- GoClick = "GoClick",
1540 -- UnlockLua = "UnlockLua",
1541 -- SimpleUnlock = "SimpleUnlock"
1542 -- }
1543
1544 CreateDirectory = CreateDirectoryLua
1545 GetKeyState = GetKeyStateLua
1546 ObjectCount = GetObjectCount
1547 GetObjectFacing = ObjectFacing
1548 ObjectWithIndex = GetObjectWithIndex
1549 GetObjectFromGUID = GetObjectWithGUID
1550 if EWT.wowBuild == 5875 then
1551 UnitGUID = ObjectGUID
1552 else
1553 -- ObjectGUID = UnitGUID
1554 end
1555 ObjectName = UnitName
1556 EWT.setInteractUnit = InteractUnit == nil
1557 if EWT.setInteractUnit then
1558 InteractUnit = ObjectInteract
1559 end
1560 UnitCreator = ObjectCreator
1561 GetFireHackDirectory = GetHackDirectory
1562 SetOptionEnabled = SetHackEnabled
1563 CastAtPosition = ClickPosition
1564 CancelPendingSpell = SpellStopTargeting
1565 UnitSetDisplayID = SetDisplayID
1566 UnitUpdateModel = UpdateModel
1567 IsAoEPending = SpellIsTargeting
1568 if not UnitIsTappedByPlayer then
1569 UnitIsTappedByPlayer = function(arg)
1570 return false
1571 end
1572 end
1573
1574 -- local Distance = 2;
1575 -- local Precision = 3;
1576
1577 local Target = nil;
1578 local TargetName = nil;
1579
1580 local function StopFollowing ()
1581 if IsHackEnabled("freeze") then StopMoving() return true end
1582 if Target then
1583 Target = nil;
1584 MoveTo(ObjectPosition("Player"));
1585
1586 AutoFollowStatus.fadeTime = AUTOFOLLOW_STATUS_FADETIME;
1587 AutoFollowStatusText:SetFormattedText(AUTOFOLLOWSTOP, TargetName);
1588 AutoFollowStatus:Show();
1589 end
1590 return false
1591 end
1592
1593 local function UpdateFollowPosition ()
1594 if Target then
1595 if not UnitExists(Target) or not UnitIsVisible(Target) or UnitIsDead("Player") then
1596 StopFollowing();
1597 else
1598 local PlayerX, PlayerY, PlayerZ = ObjectPosition("Player");
1599 local TargetX, TargetY, TargetZ = ObjectPosition(Target);
1600
1601 if GetDistanceBetweenPositions(PlayerX, PlayerY, PlayerZ, TargetX, TargetY, TargetZ) >= 3 then
1602 local AngleXY, AngleXYZ = GetAnglesBetweenPositions(TargetX, TargetY, TargetZ, PlayerX, PlayerY, PlayerZ);
1603 MoveTo(GetPositionFromPosition(TargetX, TargetY, TargetZ, 2, AngleXY, AngleXYZ));
1604 else
1605 local Angle = GetAnglesBetweenPositions(PlayerX, PlayerY, PlayerZ, TargetX, TargetY, TargetZ);
1606 FaceDirection(Angle, false);
1607 end
1608 end
1609 end
1610 end
1611
1612 local function round2(num, numDecimalPlaces)
1613 return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
1614 end
1615
1616 local initNavigation = false
1617 local ewtPath = nil
1618 local pathIndex = 1
1619 local stuckCount = 0
1620 local lastX, lastY, lastZ = 0, 0, 0
1621 local function UpdateGotoPosition()
1622 if ewtPath ~= nil then
1623 local PlayerX, PlayerY, PlayerZ = ObjectPosition("Player");
1624 local destX = ewtPath[pathIndex][1]
1625 local destY = ewtPath[pathIndex][2]
1626 local destZ = ewtPath[pathIndex][3]
1627 -- if GetDistanceBetweenPositions(PlayerX, PlayerY, PlayerZ, destX, destY, destZ) < 1.5 then
1628 if sqrt(((destX - PlayerX) ^ 2) + ((destY - PlayerY) ^ 2)) < 1 and math.abs(destZ - PlayerZ) < 4 then
1629 pathIndex = pathIndex + 1
1630 print('Moving to next coordinates')
1631 if pathIndex > table.getn(ewtPath) then
1632 pathIndex = 1
1633 ewtPath = nil
1634 end
1635 else
1636 PlayerX, PlayerY, PlayerZ = round2(PlayerX, 3), round2(PlayerY, 3), round2(PlayerZ, 3)
1637 if lastX == PlayerX and lastY == PlayerY and lastZ == PlayerZ then
1638 stuckCount = stuckCount + 1
1639 if stuckCount > 10 then -- not precise because FPS might affect it
1640 print('Stuck jumping...')
1641 JumpOrAscendStart()
1642 stuckCount = 0
1643 end
1644 else
1645 stuckCount = 0
1646 end
1647 MoveTo(destX, destY, destZ)
1648 lastX = PlayerX
1649 lastY = PlayerY
1650 lastZ = PlayerZ
1651 end
1652 end
1653 end
1654
1655 function GoTo(toX, toY, toZ)
1656 if initNavigation == false then
1657 print('Loading meshes... please wait.')
1658 InitializeNavigation(function(result)
1659 if result == true then
1660 print('Initialized meshes')
1661 initNavigation = true
1662 GoTo(toX, toY, toZ)
1663 else
1664 print('Failed to initialize meshes.')
1665 end
1666 end)
1667 else
1668 pathIndex = 1
1669 ewtPath = nil
1670 local PlayerX, PlayerY, PlayerZ = ObjectPosition("Player");
1671 ewtPath, totalDistance = CalculatePath(GetMapId(), PlayerX, PlayerY, PlayerZ, toX, toY, toZ, true, true, 0)
1672 print('Created path ' .. table.getn(ewtPath) .. ' Distance ' .. totalDistance)
1673 end
1674 end
1675
1676 local isAprilFools = false
1677 local aprilFoolsMsg = false
1678 if EWT.is80 and C_Calendar ~= nil then
1679 local date = C_Calendar.GetDate()
1680 if date.monthDay == 1 and date.month == 4 then
1681 isAprilFools = true
1682 end
1683 end
1684
1685 -- Avoid infinite loop if we call protectedFunctions["UnloadEWT"]. We could also make UnloadEWT = nil after everything.
1686 -- UnloadEWT can be used by rotation developers to shutdown WoW when a subscription ends.
1687 local origUnload = UnloadEWT
1688 local protectedFunctions = {}
1689 local ShutdownHook = function(Name)
1690 return origUnload("You are not allowed to hook " .. Name)
1691 end
1692
1693 local SetupUnhookableFunction = function(Name)
1694 local OldFunction = protectedFunctions[Name]
1695 if OldFunction ~= nil then
1696 return false
1697 end
1698 local GlobalFunction = _G[Name]
1699 if GlobalFunction == nil then
1700 return false
1701 end
1702 _G[Name] = function(a,b,c,d,e,f,g,h) -- because of 1.12.1 Lua 5.0
1703 if _G[Name] ~= protectedFunctions[Name] then
1704 ShutdownHook(Name)
1705 return
1706 end
1707 return GlobalFunction(a,b,c,d,e,f,g,h)
1708 end
1709 protectedFunctions[Name] = _G[Name]
1710 return true
1711 end
1712
1713 local FunctionsToProtect = {
1714 "SendHTTPRequest", "ReadMemory", "RunString", "RunScript", "RegisterLuaFunction", "GetModuleAddress", "GetOffset", "UnloadEWT",
1715 "AddLuaString", "RunEWTCommand", "ObjectLevel"
1716 }
1717
1718 local ReRegisterFunction = function(offset, name)
1719 local ofs = GetOffset(offset)
1720 if EWT.is80 and ofs > 0 and ofs < 2147483647 then
1721 RegisterLuaFunction(name, GetModuleAddress() + ofs)
1722 end
1723 end
1724 -- This causes Lua executed by /run or /script to be unlocked if using the tainted=0 version
1725 -- Also be careful with detection on private servers running Lua scans.
1726 ReRegisterFunction("Script_RunScript", "RunScript")
1727 -- UnloadEWT = nil
1728
1729 -- GetTime is always declared. It uses seconds.
1730 local startStamp = GetTime()
1731 local monitorStamp = startStamp
1732 local monitorAddons = {"BadRotations", "NerdPack", "dark_addon", "DoMeWhen-Classic", "DoMeWhen", "!orcacustomer", "!gold"}
1733 local monitorGlobals = {"HF_StartStop", "ObjectManagerUpdate", "dr_info_frame", "NeP", "GMR_Print", "LibDBIcon10_DMWMinimapIcon", "badmen", "orcaF", "x33CD6hXLirKUWpM53cZQcjraiaxQHJx4uF", "Vendor_Goal", "KW"}
1734 EWT.om = {}
1735 apiFrame:SetScript("OnUpdate",
1736 function ()
1737 local now = GetTime()
1738 if now - monitorStamp > 30 and SetCustomData ~= nil and IsAddOnLoaded ~= nil then
1739 monitorStamp = now
1740 for k,v in pairs(monitorAddons) do
1741 if IsAddOnLoaded(v) then
1742 SetCustomData(v, "true")
1743 end
1744 end
1745 for k,v in pairs(monitorGlobals) do
1746 if _G[v] ~= nil then
1747 SetCustomData(v, "true")
1748 end
1749 end
1750 if badmen ~= nil or orcaF ~= nil or IsAddOnLoaded("!orcacustomer") or IsAddOnLoaded("!gold") or _moveToXYZ ~= nil or _actualHp ~= nil then
1751 if x33CD6hXLirKUWpM53cZQcjraiaxQHJx4uF == nil then
1752 origUnload('You are using a cracked or old version of Orca. Update or purchase at https://forums.woworcabot.com')
1753 end
1754 end
1755 end
1756 -- if isAprilFools and not aprilFoolsMsg and now - startStamp > 600 and IsPlayerInWorld ~= nil and IsPlayerInWorld() then
1757 -- aprilFoolsMsg = true
1758 -- print("\124cffff80ff\124Tinterface\\ChatFrame\\UI-ChatIcon-Blizz:12:20:0:0:32:16:4:28:0:16\124t [Vislyer] whispers: Hello, " .. UnitName("player") .. ". We have detected \"UNAUTHORIZED THIRD PARTY PROGRAM\" running on your computer. Your account will be suspended and an email will be sent shortly to you describing the offense in place. Thanks for your attention.")
1759 -- EWT.flash()
1760 -- PlaySound(SOUNDKIT.TELL_MESSAGE);
1761 -- end
1762 if EWTFrameUpdate ~= nil then
1763 EWTFrameUpdate()
1764 if now - startStamp > 360 and EWT.isPrivate == false and EWT.mode == 0 and EWT.isDebug == false and IsPlayerInWorld ~= nil and IsPlayerInWorld() then
1765 -- UnloadEWT("Warden Count")
1766 end
1767 -- Object Manager debugging
1768 -- if ScriptErrorsFrame:IsShown() then
1769 -- logEWT("Error caught ")
1770 -- logEWT(ScriptErrorsFrame.ScrollFrame.Text:GetText())
1771 -- end
1772 -- local total, updated, added, removed = GetObjectCount(true, 'ewtid')
1773 -- logEWT('EWT GetObjectCount ' .. total .. ' ' .. tostring(updated) .. ' ' .. #added .. ' ' .. #removed)
1774 -- for k,v in pairs(added) do
1775 -- logEWT('Adding ' .. v)
1776 -- EWT.om[v] = 1
1777 -- end
1778 -- for k,v in pairs(removed) do
1779 -- logEWT('Removing ' .. v)
1780 -- for i,j in pairs(EWT.om) do
1781 -- if i ~= v and tonumber(i) == tonumber(v) then
1782 -- logEWT('Not found')
1783 -- print('Not Found')
1784 -- end
1785 -- end
1786 -- EWT.om[v] = nil
1787 -- end
1788 -- local manualCount = 0
1789 -- for k,v in pairs(EWT.om) do
1790 -- manualCount = manualCount + 1
1791 -- end
1792 -- if #added ~= 0 or #removed ~= 0 then
1793 -- logEWT('Total ' .. total .. ' ' .. #added .. ' ' .. #removed .. ' Manual ' .. manualCount)
1794 -- if manualCount ~= total then
1795 -- logEWT('Mismatch')
1796 -- end
1797 -- end
1798 end
1799 for _, Callback in pairs(FrameCallbacks) do
1800 Callback();
1801 end
1802 for _, Name in pairs(FunctionsToProtect) do
1803 if _G[Name] ~= protectedFunctions[Name] then
1804 ShutdownHook(Name)
1805 end
1806 end
1807 -- if EWT.wowBuild > 18414 and EWT.isClassic == false and IsHackEnabled('autogut') then
1808 -- EWT.autoGut()
1809 -- end
1810 if IsHackEnabled("relog") and GetActivePlayer() == nil then
1811 EWT.login()
1812 end
1813 if EWT.interactFlags == true then
1814 local totalObjects = GetObjectCount()
1815 local ofs = GetOffset("CGGameObjectData__DisplayID")
1816 for i = 1, totalObjects do
1817 local obj = ObjectWithIndex(i)
1818 if ObjectIsGameObject(obj) then
1819 local displayId = ObjectDescriptor(obj, ofs, "int")
1820 if (displayId == 5912 or displayId == 5913) and GetDistanceBetweenObjects("player", obj) < 5 then
1821 InteractUnit(obj)
1822 end
1823 end
1824 end
1825 end
1826 UpdateFollowPosition()
1827 UpdateGotoPosition()
1828 -- if ChatFrame1 ~= nil then
1829 -- local c=ChatFrame1:GetNumMessages()
1830 -- for i=1,c do
1831 -- local t=ChatFrame1:GetMessageInfo(i)
1832 -- if string.find(t,'account') ~= nil then
1833 -- logEWT('Detected Tauri')
1834 -- end
1835 -- if string.find(t,'Unauthorized') ~= nil then
1836 -- logEWT('Detected Warmane')
1837 -- end
1838 -- end
1839 -- end
1840 end
1841 );
1842
1843 function EWT.FollowUnit (Unit)
1844 if Unit then
1845 if UnitExists(Unit) and UnitIsVisible(Unit) and not UnitIsUnit(Unit, "Player") then
1846 Target = ObjectPointer(Unit);
1847 TargetName = UnitName(Unit);
1848 AutoFollowStatus.fadeTime = nil;
1849 AutoFollowStatus:SetAlpha(1.0);
1850 AutoFollowStatusText:SetFormattedText(AUTOFOLLOWSTART, TargetName);
1851 AutoFollowStatus:Show();
1852 else
1853 UIErrorsFrame:AddMessage(ERR_INVALID_FOLLOW_TARGET, 1, 0, 0);
1854 end
1855 elseif Target then
1856 StopFollowing();
1857 end
1858 end
1859
1860 -- 1.12.1 doesnt have JumpOrAscendStart
1861 if EWT.wowBuild == 5875 then
1862 JumpOrAscendStart = Jump
1863 end
1864
1865 ----- REMOVE BEGIN
1866
1867 if EWT.isClassic then
1868 IsFlying = function() return false end
1869 end
1870
1871 local JumpOrAscendStart_Trampoline = JumpOrAscendStart;
1872 JumpOrAscendStart = function (...)
1873 if IsHackEnabled("freeze") then return true end
1874 if IsFlying() or IsSwimming() then
1875 StopFollowing();
1876 end
1877 return JumpOrAscendStart_Trampoline(...);
1878 end
1879
1880 local SitStandOrDescendStart_Trampoline = SitStandOrDescendStart;
1881 SitStandOrDescendStart = function (...)
1882 if StopFollowing() then return end
1883 return SitStandOrDescendStart_Trampoline(...);
1884 end
1885
1886 local ToggleAutoRun_Trampoline = ToggleAutoRun;
1887 ToggleAutoRun = function (...)
1888 if StopFollowing() then return end
1889 return ToggleAutoRun_Trampoline(...);
1890 end
1891
1892 local TurnLeftStart_Trampoline = TurnLeftStart;
1893 TurnLeftStart = function (...)
1894 if StopFollowing() then return end
1895 return TurnLeftStart_Trampoline(...);
1896 end
1897
1898 local TurnRightStart_Trampoline = TurnRightStart;
1899 TurnRightStart = function (...)
1900 if StopFollowing() then return end
1901 return TurnRightStart_Trampoline(...);
1902 end
1903
1904 local TurnOrActionStart_Trampoline = TurnOrActionStart;
1905 TurnOrActionStart = function (...)
1906 if StopFollowing() then return end
1907 return TurnOrActionStart_Trampoline(...);
1908 end
1909
1910 -- local TurnOrActionStop_Trampoline = TurnOrActionStop;
1911 -- TurnOrActionStop = function (...)
1912 -- return TurnOrActionStop_Trampoline(...);
1913 -- end
1914
1915 -- local MouselookStart_Trampoline = MouselookStart;
1916 -- MouselookStart = function (...)
1917 -- return MouselookStart_Trampoline(...);
1918 -- end
1919
1920 -- local MouselookStop_Trampoline = MouselookStop;
1921 -- MouselookStop = function (...)
1922 -- return MoveAndSteerStop_Trampoline(...);
1923 -- end
1924
1925 local MoveAndSteerStart_Trampoline = MoveAndSteerStart;
1926 MoveAndSteerStart = function (...)
1927 if StopFollowing() then return end
1928 return MoveAndSteerStart_Trampoline(...);
1929 end
1930
1931 local MoveAndSteerStop_Trampoline = MoveAndSteerStop;
1932 MoveAndSteerStop = function (...)
1933 if StopFollowing() then return end
1934 return MoveAndSteerStop_Trampoline(...);
1935 end
1936
1937 local MoveForwardStart_Trampoline = MoveForwardStart;
1938 MoveForwardStart = function (...)
1939 if StopFollowing() then return end
1940 return MoveForwardStart_Trampoline(...);
1941 end
1942
1943 local MoveForwardStop_Trampoline = MoveForwardStop;
1944 MoveForwardStop = function (...)
1945 if StopFollowing() then return end
1946 return MoveForwardStop_Trampoline(...);
1947 end
1948
1949 local MoveBackwardStart_Trampoline = MoveBackwardStart;
1950 MoveBackwardStart = function (...)
1951 if StopFollowing() then return end
1952 return MoveBackwardStart_Trampoline(...);
1953 end
1954
1955 local MoveBackwardStop_Trampoline = MoveBackwardStop;
1956 MoveBackwardStop = function (...)
1957 if StopFollowing() then return end
1958 return MoveBackwardStop_Trampoline(...);
1959 end
1960
1961 local StrafeLeftStart_Trampoline = StrafeLeftStart;
1962 StrafeLeftStart = function (...)
1963 if StopFollowing() then return end
1964 return StrafeLeftStart_Trampoline(...);
1965 end
1966
1967 local StrafeLeftStop_Trampoline = StrafeLeftStop;
1968 StrafeLeftStop = function (...)
1969 if StopFollowing() then return end
1970 return StrafeLeftStop_Trampoline(...);
1971 end
1972
1973 local StrafeRightStart_Trampoline = StrafeRightStart;
1974 StrafeRightStart = function (...)
1975 if StopFollowing() then return end
1976 return StrafeRightStart_Trampoline(...);
1977 end
1978
1979 local StrafeRightStop_Trampoline = StrafeRightStop;
1980 StrafeRightStop = function (...)
1981 if StopFollowing() then return end
1982 return StrafeRightStop_Trampoline(...);
1983 end
1984
1985 function StopMoving()
1986 StrafeRightStop_Trampoline()
1987 StrafeLeftStop_Trampoline()
1988 MoveBackwardStop_Trampoline()
1989 MoveForwardStop_Trampoline()
1990 MoveAndSteerStop_Trampoline()
1991 end
1992
1993 SLASH_FOLLOWEWT1 = "/followewt";
1994 -- SLASH_FOLLOW2 = "/f";
1995 if SlashCmdList ~= nil then
1996 SlashCmdList["FOLLOWEWT"] = function (Message, EditBox)
1997 EWT.FollowUnit("target");
1998 end
1999 end
2000
2001 -- Panda WoW
2002 if EWT.wowBuild == 18414 then
2003 SendAddonMessage = function(...) end
2004 end
2005
2006 ----- REMOVE END
2007
2008 if EWT.enableLibDraw then
2009 EWT.enableLibDraw()
2010 end
2011
2012 function EWT.LibDrawTest()
2013 LibDraw.Sync(function()
2014 if UnitExists("target") then
2015 local playerX, playerY, playerZ = ObjectPosition("player")
2016 local targetX, targetY, targetZ = ObjectPosition("target")
2017 local reaction = UnitReaction("player", "target")
2018 if reaction >= 5 then
2019 LibDraw.SetColorRaw(0, 1, 0, 1)
2020 elseif reaction == 4 then
2021 LibDraw.SetColorRaw(1, 1, 0, 1)
2022 elseif reaction <= 3 then
2023 LibDraw.SetColorRaw(1, 0, 0, 1)
2024 end
2025 LibDraw.Line(playerX, playerY, playerZ, targetX, targetY, targetZ)
2026 -- LibDraw.Circle(targetX, targetY, targetZ, 5)
2027 end
2028 end)
2029 LibDraw.Enable(0.01)
2030 end
2031
2032 -- After everything has been setup
2033 for _, Name in pairs(FunctionsToProtect) do
2034 SetupUnhookableFunction(Name)
2035 end
2036
2037 end -- end of EnableAPI
2038
2039 function EWT.disableLibDraw()
2040 if LibDrawTimer then
2041 LibDrawTimer:Cancel()
2042 LibDrawTimer = nil
2043 end
2044 if LibDraw then
2045 LibDraw.clearCanvas()
2046 end
2047 end
2048
2049 function EWT.DisableAPI()
2050 EWT.disableLibDraw()
2051 FireHack = nil;
2052 ObjectIsType = nil; ObjectIsFacing = nil; IsAoEPending = nil; GetDistanceBetweenObjects = nil;
2053 GetDistanceBetweenPositions = nil; SetOptionEnabled = nil; UnitSetDisplayID = nil; GetGroundZ = nil;
2054 ObjectCount = nil; ObjectWithIndex = nil; ObjectTypes = nil; Types = nil; GetObjectFacing = nil; UnitUpdateModel = nil;
2055 ObjectType = nil; GetFireHackDirectory = nil; ObjectGUID = nil; ObjectName = nil; ObjectInteract = nil;
2056 CastAtPosition = nil; WorldToScreen = nil; WorldToScreen_Original = nil; Hacks = nil; CancelPendingSpell = nil; GetObjectFromGUID = nil;
2057 LibDrawTimer = nil; LibDraw = nil; GetAnglesBetweenPositions = nil; GetAnglesBetweenObjects = nil;
2058 GetPositionBetweenObjects = nil; ObjectIsBehind = nil; GetPositionFromPosition = nil; GetPositionBetweenPositions = nil;
2059 ObjectID = nil; GetDescriptor = nil; GetDirectoryFiles = nil; GetSubdirectories = nil; MovementFlags = nil; HitFlags = nil;
2060 UnitCreator = nil; CreateTimer = nil; SplitString = nil; AddTeleportCallbacks = nil; TeleportToCorpse = nil;
2061 ObjectIsPlayer = nil; ObjectIsUnit = nil; ObjectIsGameObject = nil; ObjectIsAreaTrigger = nil; EWTCreateListing = nil;
2062 if EWT.setInteractUnit then
2063 InteractUnit = nil
2064 end
2065 for Name, OldFunction in pairs(UnlockedFunctions) do
2066 _G[Name] = OldFunction
2067 end
2068 for Namespace, Table in pairs(UnlockedNamespaces) do
2069 for k, v in pairs(Table) do
2070 _G[Namespace][k] = v
2071 end
2072 end
2073 if EWT.is73 then
2074 ChatEdit_SendText = EWT.oldSendText
2075 end
2076 apiFrame:SetScript("OnEvent", nil)
2077 apiFrame:SetScript("OnUpdate", nil)
2078 -- apiFrame = nil
2079 end
2080
2081 function EWT.Unload()
2082 ewtFrame:SetScript("OnEvent", nil);
2083 ewtFrame:SetScript("OnUpdate", nil);
2084 ewtFrame:Hide();
2085 EasyWoWToolbox = nil;
2086 EWT = nil;
2087 end
2088
2089 function EWT.APITest()
2090 TargetUnit("player")
2091 local error = 0
2092 -- if ObjectDescriptor("player", 0x1B0, "float") ~= UnitCombatReach("player") then
2093 -- error = 1
2094 -- end
2095 if ObjectGUID("player") ~= UnitGUID("player") then
2096 error = 2
2097 end
2098 local x, y, z = ObjectPosition("player")
2099 if not x or not y or not z then
2100 error = 3
2101 end
2102 FaceDirection(3)
2103 if ObjectFacing("player") ~= 3 then
2104 error = 4
2105 end
2106 SetHackEnabled("M2Collision", false)
2107 if IsHackEnabled("M2Collision") then
2108 error = 5
2109 end
2110 SetHackEnabled("M2Collision", true)
2111 if GetObjectWithGUID(UnitGUID("player")) ~= ObjectPointer("player") then
2112 error = 6
2113 end
2114 -- if UnitTarget("player") ~= GetObjectWithGUID(ObjectDescriptor("player", 0xA0, "guid")) then
2115 -- error = 7
2116 -- end
2117 -- if ObjectIsPlayer("player") ~= true then
2118 -- error = 8
2119 -- end
2120 print("Error " .. error)
2121 end
2122
2123 -- if DevTools_Dump then
2124 -- print('DevTools_Dump Available')
2125 -- SlashCmdList["DUMP"] = function(msg)
2126 -- RunScript("DevTools_Dump({"..msg.."})")
2127 -- end
2128 -- SlashCmdList["SCRIPT"] = function(msg, msg2, msg3)
2129 -- RunScript(msg)
2130 -- end
2131 -- end
2132
2133 function EWT.handleBeta()
2134 EWT.print("Beta build: /reload to load addons and enable /script and /run commands.")
2135 SlashCmdList["SCRIPT"] = function(msg, msg2, msg3)
2136 RunScript(msg)
2137 end
2138 end
2139
2140 ----- REMOVE BEGIN
2141
2142 function EWT.enableLibDraw()
2143
2144 -- if LibDraw then return end
2145
2146 local sin, cos, atan, atan2, sqrt, rad = math.sin, math.cos, math.atan, math.atan2, math.sqrt, math.rad
2147 local tinsert, tremove = tinsert, tremove
2148
2149 -- patch WorldToScreen for 6.2 / 2.1.2 update
2150 local WorldToScreen_Original2 = WorldToScreen;
2151 local function WorldToScreen (wX, wY, wZ)
2152 local sX, sY = WorldToScreen_Original2(wX, wY, wZ);
2153 if sX and sY then
2154 return sX, -(WorldFrame:GetTop() - sY);
2155 else
2156 return sX, sY;
2157 end
2158 end
2159
2160 LibDraw = {
2161 version = 1.1
2162 }
2163
2164 LibDraw.line = LibDraw.line or {r = 0, g = 1, b = 0, a = 1, w = 20}
2165 LibDraw.texture = "Interface\\TaxiFrame\\UI-Taxi-Line"
2166 LibDraw.level = "BACKGROUND"
2167 LibDraw.callbacks = {}
2168
2169 if not LibDraw.canvas then
2170 LibDraw.canvas = CreateFrame("Frame", WorldFrame)
2171 LibDraw.canvas:SetAllPoints(WorldFrame)
2172 LibDraw.textures = {}
2173 LibDraw.textures_used = {}
2174 LibDraw.fontstrings = {}
2175 LibDraw.fontstrings_used = {}
2176 end
2177
2178 function LibDraw.SetColor(r, g, b, a)
2179 LibDraw.line.r = r * 0.00390625
2180 LibDraw.line.g = g * 0.00390625
2181 LibDraw.line.b = b * 0.00390625
2182 if a then
2183 LibDraw.line.a = a * 0.01
2184 else
2185 LibDraw.line.a = 1
2186 end
2187 end
2188
2189 function LibDraw.SetColorRaw(r, g, b, a)
2190 LibDraw.line.r = r
2191 LibDraw.line.g = g
2192 LibDraw.line.b = b
2193 LibDraw.line.a = a
2194 end
2195
2196 function LibDraw.SetWidth(w)
2197 LibDraw.line.w = w
2198 end
2199
2200 function LibDraw.Line(sx, sy, sz, ex, ey, ez)
2201 if not FireHack then return end
2202
2203 local sx, sy = WorldToScreen(sx, sy, sz)
2204 local ex, ey = WorldToScreen(ex, ey, ez)
2205
2206 LibDraw.Draw2DLine(sx, sy, ex, ey)
2207 end
2208
2209 function LibDraw.rotateX(cx, cy, cz, px, py, pz, r)
2210 if r == nil then return px, py, pz end
2211 local s = sin(r)
2212 local c = cos(r)
2213 -- center of rotation
2214 px, py, pz = px - cx, py - cy, pz - cz
2215 local x = px + cx
2216 local y = ((py * c - pz * s) + cy)
2217 local z = ((py * s + pz * c) + cz)
2218 return x, y, z
2219 end
2220
2221 function LibDraw.rotateY(cx, cy, cz, px, py, pz, r)
2222 if r == nil then return px, py, pz end
2223 local s = sin(r)
2224 local c = cos(r)
2225 -- center of rotation
2226 px, py, pz = px - cx, py - cy, pz - cz
2227 local x = ((pz * s + px * c) + cx)
2228 local y = py + cy
2229 local z = ((pz * c - px * s) + cz)
2230 return x, y, z
2231 end
2232
2233 function LibDraw.rotateZ(cx, cy, cz, px, py, pz, r)
2234 if r == nil then return px, py, pz end
2235 local s = sin(r)
2236 local c = cos(r)
2237 -- center of rotation
2238 px, py, pz = px - cx, py - cy, pz - cz
2239 local x = ((px * c - py * s) + cx)
2240 local y = ((px * s + py * c) + cy)
2241 local z = pz + cz
2242 return x, y, z
2243 end
2244
2245 function LibDraw.Array(vectors, x, y, z, rotationX, rotationY, rotationZ)
2246 for _, vector in ipairs(vectors) do
2247 local sx, sy, sz = x + vector[1], y + vector[2], z + vector[3]
2248 local ex, ey, ez = x + vector[4], y + vector[5], z + vector[6]
2249
2250 if rotationX then
2251 sx, sy, sz = LibDraw.rotateX(x, y, z, sx, sy, sz, rotationX)
2252 ex, ey, ez = LibDraw.rotateX(x, y, z, ex, ey, ez, rotationX)
2253 end
2254 if rotationY then
2255 sx, sy, sz = LibDraw.rotateY(x, y, z, sx, sy, sz, rotationY)
2256 ex, ey, ez = LibDraw.rotateY(x, y, z, ex, ey, ez, rotationY)
2257 end
2258 if rotationZ then
2259 sx, sy, sz = LibDraw.rotateZ(x, y, z, sx, sy, sz, rotationZ)
2260 ex, ey, ez = LibDraw.rotateZ(x, y, z, ex, ey, ez, rotationZ)
2261 end
2262
2263 local sx, sy = WorldToScreen(sx, sy, sz)
2264 local ex, ey = WorldToScreen(ex, ey, ez)
2265 LibDraw.Draw2DLine(sx, sy, ex, ey)
2266 end
2267 end
2268
2269 local LINEFACTOR = 256 / 254;
2270 local LINEFACTOR_2 = LINEFACTOR / 2;
2271
2272 function LibDraw.Draw2DLine(sx, sy, ex, ey)
2273 if not FireHack or not sx or not sy or not ex or not ey then return end
2274
2275 local T = tremove(LibDraw.textures) or false
2276 if T == false then
2277 T = LibDraw.canvas:CreateTexture(nil, "BACKGROUND")
2278 T:SetDrawLayer(LibDraw.level)
2279 end
2280
2281 T:SetTexture(LibDraw.texture)
2282 tinsert(LibDraw.textures_used, T)
2283
2284 -- Determine dimensions and center point of line
2285 local dx, dy = ex - sx, ey - sy
2286 local cx, cy = (sx + ex) * 0.5, (sy + ey) * 0.5
2287
2288 -- Normalize direction if necessary
2289 if (dx < 0) then
2290 dx, dy = -dx, -dy
2291 end
2292
2293 -- Calculate actual length of line
2294 local l = sqrt((dx * dx) + (dy * dy))
2295
2296 -- Quick escape if it's zero length
2297 if (l == 0) then
2298 T:SetTexCoord(0, 0, 0, 0, 0, 0, 0, 0)
2299 T:SetPoint("BOTTOMLEFT", C, "TOPLEFT", cx, cy)
2300 T:SetPoint("TOPRIGHT", C, "TOPLEFT", cx, cy)
2301 return
2302 end
2303
2304 -- Sin and Cosine of rotation, and combination (for later)
2305 local s, c = -dy / l, dx / l
2306 local sc = s * c
2307
2308 -- Calculate bounding box size and texture coordinates
2309 local Bwid, Bhgt, BLx, BLy, TLx, TLy, TRx, TRy, BRx, BRy
2310 if (dy >= 0) then
2311 Bwid = ((l * c) - (LibDraw.line.w * s)) * LINEFACTOR_2
2312 Bhgt = ((LibDraw.line.w * c) - (l * s)) * LINEFACTOR_2
2313 BLx, BLy, BRy = (LibDraw.line.w / l) * sc, s * s, (l / LibDraw.line.w) * sc
2314 BRx, TLx, TLy, TRx = 1 - BLy, BLy, 1 - BRy, 1 - BLx
2315 TRy = BRx;
2316 else
2317 Bwid = ((l * c) + (LibDraw.line.w * s)) * LINEFACTOR_2
2318 Bhgt = ((LibDraw.line.w * c) + (l * s)) * LINEFACTOR_2
2319 BLx, BLy, BRx = s * s, -(l / LibDraw.line.w) * sc, 1 + (LibDraw.line.w / l) * sc
2320 BRy, TLx, TLy, TRy = BLx, 1 - BRx, 1 - BLx, 1 - BLy
2321 TRx = TLy
2322 end
2323
2324 if TLx > 10000 then TLx = 10000 elseif TLx < -10000 then TLx = -10000 end
2325 if TLy > 10000 then TLy = 10000 elseif TLy < -10000 then TLy = -10000 end
2326 if BLx > 10000 then BLx = 10000 elseif BLx < -10000 then BLx = -10000 end
2327 if BLy > 10000 then BLy = 10000 elseif BLy < -10000 then BLy = -10000 end
2328 if TRx > 10000 then TRx = 10000 elseif TRx < -10000 then TRx = -10000 end
2329 if TRy > 10000 then TRy = 10000 elseif TRy < -10000 then TRy = -10000 end
2330 if BRx > 10000 then BRx = 10000 elseif BRx < -10000 then BRx = -10000 end
2331 if BRy > 10000 then BRy = 10000 elseif BRy < -10000 then BRy = -10000 end
2332
2333 T:ClearAllPoints()
2334
2335 -- Set texture coordinates and anchors
2336 T:SetTexCoord(TLx, TLy, BLx, BLy, TRx, TRy, BRx, BRy)
2337 T:SetPoint("BOTTOMLEFT", LibDraw.canvas, "TOPLEFT", cx - Bwid, cy - Bhgt)
2338 T:SetPoint("TOPRIGHT", LibDraw.canvas, "TOPLEFT", cx + Bwid, cy + Bhgt)
2339 T:SetVertexColor(LibDraw.line.r, LibDraw.line.g, LibDraw.line.b, LibDraw.line.a)
2340 T:Show()
2341
2342 end
2343
2344 local full_circle = rad(365)
2345 local small_circle_step = rad(3)
2346
2347 function LibDraw.Circle(x, y, z, size)
2348 local lx, ly, nx, ny, fx, fy = false, false, false, false, false, false
2349 for v = 0, full_circle, small_circle_step do
2350 nx, ny = WorldToScreen((x + cos(v) * size), (y + sin(v) * size), z)
2351 LibDraw.Draw2DLine(lx, ly, nx, ny)
2352 lx, ly = nx, ny
2353 end
2354 end
2355
2356 local flags = bit.bor(0x100)
2357
2358 function LibDraw.GroundCircle(x, y, z, size)
2359 local lx, ly, nx, ny, fx, fy, fz = false, false, false, false, false, false, false
2360 for v = 0, full_circle, small_circle_step do
2361 fx, fy, fz = TraceLine((x + cos(v) * size), (y + sin(v) * size), z + 100, (x + cos(v) * size), (y + sin(v) * size), z - 100, flags)
2362 if fx == nil then
2363 fx, fy, fz = (x + cos(v) * size), (y + sin(v) * size), z
2364 end
2365 nx, ny = WorldToScreen((fx + cos(v) * size), (fy + sin(v) * size), fz)
2366 LibDraw.Draw2DLine(lx, ly, nx, ny)
2367 lx, ly = nx, ny
2368 end
2369 end
2370
2371 function LibDraw.Arc(x, y, z, size, arc, rotation)
2372 local lx, ly, nx, ny, fx, fy = false, false, false, false, false, false
2373 local half_arc = arc * 0.5
2374 local ss = (arc / half_arc)
2375 local as, ae = -half_arc, half_arc
2376 for v = as, ae, ss do
2377 nx, ny = WorldToScreen((x + cos(rotation + rad(v)) * size), (y + sin(rotation + rad(v)) * size), z)
2378 if lx and ly then
2379 LibDraw.Draw2DLine(lx, ly, nx, ny)
2380 else
2381 fx, fy = nx, ny
2382 end
2383 lx, ly = nx, ny
2384 end
2385 local px, py = WorldToScreen(x, y, z)
2386 LibDraw.Draw2DLine(px, py, lx, ly)
2387 LibDraw.Draw2DLine(px, py, fx, fy)
2388 end
2389
2390 function LibDraw.Texture(config, x, y, z, alphaA)
2391
2392 local texture, width, height = config.texture, config.width, config.height
2393 local left, right, top, bottom, scale = config.left, config.right, config.top, config.bottom, config.scale
2394 local alpha = config.alpha or alphaA
2395
2396 if not FireHack or not texture or not width or not height or not x or not y or not z then return end
2397 if not left or not right or not top or not bottom then
2398 left = 0
2399 right = 1
2400 top = 0
2401 bottom = 1
2402 end
2403 if not scale then
2404 local cx, cy, cz = GetCameraPosition()
2405 scale = width / LibDraw.Distance(x, y, z, cx, cy, cz)
2406 end
2407
2408 local sx, sy = WorldToScreen(x, y, z)
2409 if not sx or not sy then return end
2410 local w = width * scale
2411 local h = height * scale
2412 sx = sx - w * 0.5
2413 sy = sy + h * 0.5
2414 local ex, ey = sx + w, sy - h
2415
2416 local T = tremove(LibDraw.textures) or false
2417 if T == false then
2418 T = LibDraw.canvas:CreateTexture(nil, "BACKGROUND")
2419 T:SetDrawLayer(LibDraw.level)
2420 T:SetTexture(LibDraw.texture)
2421 end
2422 tinsert(LibDraw.textures_used, T)
2423 T:ClearAllPoints()
2424 T:SetTexCoord(left, right, top, bottom)
2425 T:SetTexture(texture)
2426 T:SetWidth(width)
2427 T:SetHeight(height)
2428 T:SetPoint("TOPLEFT", LibDraw.canvas, "TOPLEFT", sx, sy)
2429 T:SetPoint("BOTTOMRIGHT", LibDraw.canvas, "TOPLEFT", ex, ey)
2430 T:SetVertexColor(1, 1, 1, 1)
2431 if alpha then T:SetAlpha(alpha) else T:SetAlpha(1) end
2432 T:Show()
2433
2434 end
2435
2436 function LibDraw.Text(text, font, x, y, z)
2437
2438 local sx, sy = WorldToScreen(x, y, z)
2439
2440 if sx and sy then
2441
2442 local F = tremove(LibDraw.fontstrings) or LibDraw.canvas:CreateFontString(nil, "BACKGROUND")
2443
2444 F:SetFontObject(font)
2445 F:SetText(text)
2446 F:SetTextColor(LibDraw.line.r, LibDraw.line.g, LibDraw.line.b, LibDraw.line.a)
2447
2448 if p then
2449 local width = F:GetStringWidth() - 4
2450 local offsetX = width * 0.5
2451 local offsetY = F:GetStringHeight() + 3.5
2452 local pwidth = width * p * 0.01
2453 FHAugment.drawLine(sx - offsetX, sy - offsetY, (sx + offsetX), sy - offsetY, 4, r, g, b, 0.25)
2454 FHAugment.drawLine(sx - offsetX, sy - offsetY, (sx + offsetX) - (width - pwidth), sy - offsetY, 4, r, g, b, 1)
2455 end
2456
2457 F:SetPoint("TOPLEFT", UIParent, "TOPLEFT", sx - (F:GetStringWidth() * 0.5), sy)
2458 F:Show()
2459
2460 tinsert(LibDraw.fontstrings_used, F)
2461
2462 end
2463
2464 end
2465
2466 local rad90 = math.rad(-90)
2467
2468 function LibDraw.Box(x, y, z, width, height, rotation, offset_x, offset_y)
2469
2470 if not offset_x then offset_x = 0 end
2471 if not offset_y then offset_y = 0 end
2472
2473 if rotation then rotation = rotation + rad90 end
2474
2475 local half_width = width * 0.5
2476 local half_height = height * 0.5
2477
2478 local p1x, p1y = LibDraw.rotateZ(x, y, z, x - half_width + offset_x, y - half_width + offset_y, z, rotation)
2479 local p2x, p2y = LibDraw.rotateZ(x, y, z, x + half_width + offset_x, y - half_width + offset_y, z, rotation)
2480 local p3x, p3y = LibDraw.rotateZ(x, y, z, x - half_width + offset_x, y + half_width + offset_y, z, rotation)
2481 local p4x, p4y = LibDraw.rotateZ(x, y, z, x - half_width + offset_x, y - half_width + offset_y, z, rotation)
2482 local p5x, p5y = LibDraw.rotateZ(x, y, z, x + half_width + offset_x, y + half_width + offset_y, z, rotation)
2483 local p6x, p6y = LibDraw.rotateZ(x, y, z, x + half_width + offset_x, y - half_width + offset_y, z, rotation)
2484 local p7x, p7y = LibDraw.rotateZ(x, y, z, x - half_width + offset_x, y + half_width + offset_y, z, rotation)
2485 local p8x, p8y = LibDraw.rotateZ(x, y, z, x + half_width + offset_x, y + half_width + offset_y, z, rotation)
2486
2487 LibDraw.Line(p1x, p1y, z, p2x, p2y, z)
2488 LibDraw.Line(p3x, p3y, z, p4x, p4y, z)
2489 LibDraw.Line(p5x, p5y, z, p6x, p6y, z)
2490 LibDraw.Line(p7x, p7y, z, p8x, p8y, z)
2491
2492 end
2493
2494 local deg45 = math.rad(45)
2495 local arrowX = {
2496 {0, 0, 0, 1.5, 0, 0},
2497 {1.5, 0, 0, 1.2, 0.2, -0.2},
2498 {1.5, 0, 0, 1.2, -0.2, 0.2}}
2499 local arrowY = {
2500 {0, 0, 0, 0, 1.5, 0},
2501 {0, 1.5, 0, 0.2, 1.2, -0.2},
2502 {0, 1.5, 0, -0.2, 1.2, 0.2}}
2503 local arrowZ = {
2504 {0, 0, 0, 0, 0, 1.5},
2505 {0, 0, 1.5, 0.2, -0.2, 1.2},
2506 {0, 0, 1.5, -0.2, 0.2, 1.2}}
2507
2508 function LibDraw.DrawHelper()
2509 local playerX, playerY, playerZ = ObjectPosition("player")
2510 local old_red, old_green, old_blue, old_alpha, old_width = LibDraw.line.r, LibDraw.line.g, LibDraw.line.b, LibDraw.line.a, LibDraw.line.w
2511
2512 -- X
2513 LibDraw.SetColor(255, 0, 0, 100)
2514 LibDraw.SetWidth(1)
2515 LibDraw.Array(arrowX, playerX, playerY, playerZ, deg45, false, false)
2516 LibDraw.Text('X', "GameFontNormal", playerX + 1.75, playerY, playerZ)
2517 -- Y
2518 LibDraw.SetColor(0, 255, 0, 100)
2519 LibDraw.SetWidth(1)
2520 LibDraw.Array(arrowY, playerX, playerY, playerZ, false, -deg45, false)
2521 LibDraw.Text('Y', "GameFontNormal", playerX, playerY + 1.75, playerZ)
2522 -- Z
2523 LibDraw.SetColor(0, 0, 255, 100)
2524 LibDraw.SetWidth(1)
2525 LibDraw.Array(arrowZ, playerX, playerY, playerZ, false, false, false)
2526 LibDraw.Text('Z', "GameFontNormal", playerX, playerY, playerZ + 1.75)
2527
2528 LibDraw.line.r, LibDraw.line.g, LibDraw.line.b, LibDraw.line.a, LibDraw.line.w = old_red, old_green, old_blue, old_alpha, old_width
2529 end
2530
2531 function LibDraw.Distance(ax, ay, az, bx, by, bz)
2532 return math.sqrt(((bx - ax) * (bx - ax)) + ((by - ay) * (by - ay)) + ((bz - az) * (bz - az)))
2533 end
2534
2535 function LibDraw.Camera()
2536 local fX, fY, fZ = ObjectPosition("player")
2537 local sX, sY, sZ = GetCameraPosition()
2538 return sX, sY, sZ, atan2(sY - fY, sX - fX), atan((sZ - fZ) / sqrt(((fX - sX) ^ 2) + ((fY - sY) ^ 2)))
2539 end
2540
2541 function LibDraw.Sync(callback)
2542 tinsert(LibDraw.callbacks, callback)
2543 end
2544
2545 function LibDraw.clearCanvas()
2546 LibDraw.stats = #LibDraw.textures_used
2547 for i = #LibDraw.textures_used, 1, -1 do
2548 LibDraw.textures_used[i]:Hide()
2549 tinsert(LibDraw.textures, tremove(LibDraw.textures_used))
2550 end
2551 for i = #LibDraw.fontstrings_used, 1, -1 do
2552 LibDraw.fontstrings_used[i]:Hide()
2553 tinsert(LibDraw.fontstrings, tremove(LibDraw.fontstrings_used))
2554 end
2555 end
2556
2557 local function OnUpdate()
2558 LibDraw.clearCanvas()
2559 for _, callback in ipairs(LibDraw.callbacks) do
2560 callback()
2561 if LibDraw.helper then
2562 LibDraw.DrawHelper()
2563 end
2564 LibDraw.helper = false
2565 end
2566 end
2567
2568 function LibDraw.Enable(interval)
2569 local timer
2570 if not interval then
2571 timer = C_Timer.NewTicker(interval, OnUpdate)
2572 else
2573 timer = C_Timer.NewTicker(interval, OnUpdate)
2574 end
2575 return timer
2576 end
2577
2578 end -- End of enableLibDraw
2579
2580 ----- REMOVE END
2581
2582 -- Timing = {}
2583
2584 -- DebugFunctions = { 'GetObjectCount', 'GetObjectWithGUID', 'GetObjectWithIndex', 'ObjectExists', 'ObjectPosition', 'TraceLine',
2585 -- 'ObjectTypeFlags', 'UnitCreator', 'IsHackEnabled', 'ObjectFacing', 'UnitCombatReach' }
2586
2587 -- for i, v in pairs(DebugFunctions) do
2588 -- Timing[v] = {
2589 -- Count = 0,
2590 -- TimePerCall = 0,
2591 -- Total = 0
2592 -- }
2593 -- end
2594
2595 -- for i, v in pairs(DebugFunctions) do
2596 -- local fName = v
2597 -- _G[fName .. '_Original'] = _G[fName]
2598 -- _G[fName] = function(...)
2599 -- local start = debugprofilestop()
2600 -- local ret1, ret2, ret3, ret4 = _G[fName .. '_Original'](...)
2601 -- Timing[fName]['Count'] = Timing[fName]['Count'] + 1
2602 -- Timing[fName]['Total'] = Timing[fName]['Total'] + (debugprofilestop() - start)
2603 -- Timing[fName]['TimePerCall'] = Timing[fName]['Total'] / Timing[fName]['Count']
2604 -- return ret1, ret2, ret3, ret4
2605 -- end
2606 -- end
2607
2608 -- local startDebug = debugprofilestop()
2609 -- handleTiming = function()
2610 -- local endDebug = debugprofilestop() - startDebug
2611 -- local overhead = 0
2612 -- for i, v in pairs(Timing) do
2613 -- overhead = overhead + v['Total']
2614 -- print(string.format('%s %d %.6f %.2f %.1f/s', i, v['Count'], v['TimePerCall'], v['Total'], v['Count']*1000/endDebug))
2615 -- end
2616 -- print(string.format("> End Debug %.2f %.2f%%", debugprofilestop() - startDebug, overhead*100/endDebug))
2617 -- end
2618
2619 -- testFunction = function()
2620 -- GetObjectCount()
2621 -- end
2622
2623 -- C_Timer.NewTicker(1.0, handleTiming)
2624
2625 -- C_Timer.NewTicker(0.1, testFunction)
2626 "]:1698: RunScript()
2627 [string "local GetReqTime = function() return userdata['t'] end
2628
2629 if Should_Fail then
2630 print("Reloading UI!")
2631 RunMacroText("/reload")
2632 return
2633 end
2634
2635 function GetDir()
2636 if lb then
2637 return lb.GetBaseDirectory()
2638 else
2639 return GetHackDirectory()
2640 end
2641 end
2642
2643 function WriteData(Path, Contents, Append)
2644 if lb then
2645 return lb.WriteFile(Path, Contents, Append)
2646 else
2647 WriteFile(Path, Contents, Append)
2648 end
2649 end
2650
2651 local function HFAuth()
2652 local tokens = {
2653 'WARY', 'PALA', 'HUNT', 'ROGY', 'PRST', 'DEKA', 'SHAM', 'MAGE', 'LOCK',
2654 'MONK', 'DRUD', 'DEHU'
2655 }
2656 local HFClassID = select(3, UnitClass('player'))
2657 if lb then HFClassID = select(3, lb.UnitTagHandler(UnitClass, 'player')) end
2658 userdata['u'] = HFFramesAuth.LoginUI.Username:GetText()
2659 userdata['p'] = HFFramesAuth.LoginUI.Password:GetText()
2660 userdata['c'] = tokens[HFClassID]
2661 HFFramesAuth.LoginUI:Hide()
2662 HFFramesAuth.StatusUI:Show()
2663 if not userdata['u'] or not userdata['p'] then
2664 HFFramesAuth.StatusUI.Text:SetText('Username or Password can not be empty')
2665 return
2666 end
2667 WriteData(GetDir() .. '\\HFUser.txt', userdata['u'] .. ';' .. userdata['p'])
2668 HFDoAuth()
2669 end
2670
2671 local HF_AuthUI = function()
2672 if HFFramesAuth then
2673 HFFramesAuth.LoginUI:Show()
2674 return
2675 end
2676 local function ReadData(Path)
2677 if lb then
2678 return lb.ReadFile(Path)
2679 else
2680 return ReadFile(Path)
2681 end
2682 end
2683 local Backdrop = {
2684 bgFile = 'Interface/DialogFrame/UI-DialogBox-Background',
2685 tileSize = 32,
2686 edgeFile = 'Interface/FriendsFrame/UI-Toast-Border',
2687 tile = 1,
2688 edgeSize = 7,
2689 insets = {top = 2, right = 2, left = 3, bottom = 3}
2690 }
2691 local user = 'Username'
2692 local pas = 'Password'
2693 WriteData(GetDir() .. '\\HFUser.txt', '', true)
2694 local s = ReadData(GetDir() .. '\\HFUser.txt')
2695 if s and s ~= '' then
2696 local p1 = string.find(s, ';')
2697 if not p1 then
2698 return
2699 else
2700 user = string.sub(s, 1, p1 - 1)
2701 pas = string.sub(s, p1 + 1)
2702 end
2703 end
2704 local HFFont = DEFAULT_CHAT_FRAME:GetFont()
2705 HFFramesAuth = CreateFrame('Frame')
2706 HFFramesAuth.StatusUI = CreateFrame('Frame')
2707 HFFramesAuth.StatusUI:SetMovable(true)
2708 HFFramesAuth.StatusUI:SetBackdrop(Backdrop)
2709 HFFramesAuth.StatusUI:SetHeight(200)
2710 HFFramesAuth.StatusUI:SetWidth(200)
2711 HFFramesAuth.StatusUI:SetPoint('CENTER', 0, 0)
2712 HFFramesAuth.StatusUI:SetFrameStrata('HIGH')
2713 HFFramesAuth.StatusUI:SetClampedToScreen(true)
2714 HFFramesAuth.StatusUI.Text = HFFramesAuth.StatusUI:CreateFontString(nil,
2715 'HIGH',
2716 'GameFontNormal')
2717 HFFramesAuth.StatusUI.Text:SetAllPoints()
2718 HFFramesAuth.StatusUI.Text:SetFont(HFFont, 15, 'OUTLINE')
2719 HFFramesAuth.StatusUI.Text:SetPoint('CENTER', 0, 0)
2720 HFFramesAuth.StatusUI.Close = CreateFrame('Button', nil,
2721 HFFramesAuth.StatusUI,
2722 'UIPanelButtonTemplate')
2723 HFFramesAuth.StatusUI.Close:SetPoint('CENTER', 90, 90)
2724 HFFramesAuth.StatusUI.Close:SetScript('OnClick', function()
2725 HFFramesAuth.StatusUI:Hide()
2726 end)
2727 HFFramesAuth.StatusUI.Close:SetText('X')
2728 HFFramesAuth.StatusUI.Close:SetSize(20, 20)
2729 HFFramesAuth.StatusUI.Close:GetFontString():SetFont(HFFont, 15, 'OUTLINE')
2730 HFFramesAuth.StatusUI:Hide()
2731 HFFramesAuth.LoginUI = CreateFrame('Frame')
2732 HFFramesAuth.LoginUI:SetMovable(true)
2733 HFFramesAuth.LoginUI:SetBackdrop(Backdrop)
2734 HFFramesAuth.LoginUI:SetHeight(200)
2735 HFFramesAuth.LoginUI:SetWidth(200)
2736 HFFramesAuth.LoginUI:SetPoint('CENTER', 0, 0)
2737 HFFramesAuth.LoginUI:SetFrameStrata('HIGH')
2738 HFFramesAuth.LoginUI:SetClampedToScreen(true)
2739 HFFramesAuth.LoginUI.Text = HFFramesAuth.LoginUI:CreateFontString(nil,
2740 'HIGH',
2741 'GameFontNormal')
2742 HFFramesAuth.LoginUI.Text:SetAllPoints()
2743 HFFramesAuth.LoginUI.Text:SetText('Login to HF PvP Rotations:')
2744 HFFramesAuth.LoginUI.Text:SetFont(HFFont, 15, 'OUTLINE')
2745 HFFramesAuth.LoginUI.Text:SetPoint('TOPLEFT', 0, 120)
2746 HFFramesAuth.LoginUI.Username = CreateFrame('EditBox', nil,
2747 HFFramesAuth.LoginUI,
2748 'InputBoxTemplate')
2749 HFFramesAuth.LoginUI.Username:SetWidth(100)
2750 HFFramesAuth.LoginUI.Username:SetHeight(20)
2751 HFFramesAuth.LoginUI.Username:SetPoint('CENTER', 0, 25)
2752 HFFramesAuth.LoginUI.Username:SetAutoFocus(false)
2753 HFFramesAuth.LoginUI.Username:SetText(user)
2754 HFFramesAuth.LoginUI.Username:SetScript('OnEscapePressed', function(self)
2755 self:ClearFocus()
2756 self:SetText('Username')
2757 end)
2758 HFFramesAuth.LoginUI.Username:SetScript('OnEnterPressed', HFAuth)
2759 HFFramesAuth.LoginUI.Username:SetScript('OnTabPressed', function()
2760 HFFramesAuth.LoginUI.Password:SetFocus()
2761 end)
2762 HFFramesAuth.LoginUI.Password = CreateFrame('EditBox', nil,
2763 HFFramesAuth.LoginUI,
2764 'InputBoxTemplate')
2765 HFFramesAuth.LoginUI.Password:SetWidth(100)
2766 HFFramesAuth.LoginUI.Password:SetHeight(20)
2767 HFFramesAuth.LoginUI.Password:SetPoint('CENTER', 0, -20)
2768 HFFramesAuth.LoginUI.Password:SetAutoFocus(false)
2769 HFFramesAuth.LoginUI.Password:SetText(pas)
2770 HFFramesAuth.LoginUI.Password:SetScript('OnEscapePressed', function(self)
2771 self:ClearFocus()
2772 self:SetText('Password')
2773 end)
2774 HFFramesAuth.LoginUI.Password:SetScript('OnEnterPressed', HFAuth)
2775 HFFramesAuth.LoginUI.Password:SetScript('OnTabPressed', function()
2776 HFFramesAuth.LoginUI.Username:SetFocus()
2777 end)
2778 HFFramesAuth.LoginUI.Login = CreateFrame('Button', nil,
2779 HFFramesAuth.LoginUI,
2780 'UIPanelButtonTemplate')
2781 HFFramesAuth.LoginUI.Login:SetPoint('CENTER', 0, -70)
2782 HFFramesAuth.LoginUI.Login:SetScript('OnClick', HFAuth)
2783 HFFramesAuth.LoginUI.Login:SetText('Login')
2784 HFFramesAuth.LoginUI.Login:SetSize(150, 30)
2785 HFFramesAuth.LoginUI.Login:GetFontString():SetFont(HFFont, 15, 'OUTLINE')
2786 HFFramesAuth.LoginUI.Close = CreateFrame('Button', nil,
2787 HFFramesAuth.LoginUI,
2788 'UIPanelButtonTemplate')
2789 HFFramesAuth.LoginUI.Close:SetPoint('CENTER', 90, 90)
2790 HFFramesAuth.LoginUI.Close:SetScript('OnClick', function()
2791 HFFramesAuth.LoginUI:Hide()
2792 end)
2793 HFFramesAuth.LoginUI.Close:SetText('X')
2794 HFFramesAuth.LoginUI.Close:SetSize(20, 20)
2795 HFFramesAuth.LoginUI.Close:GetFontString():SetFont(HFFont, 15, 'OUTLINE')
2796 end
2797
2798 function AUTHCMD(msg)
2799 local msg = strtrim(msg)
2800 local space1 = string.find(msg, ' ')
2801 local space2 = nil
2802 local username = nil
2803 local pas = nil
2804 if space1 then
2805 space2 = string.find(msg, ' ', space1)
2806 if space2 then
2807 username = string.sub(msg, 1, space1 - 1)
2808 pas = string.sub(msg, space2 + 1)
2809 end
2810 end
2811 if msg and username and pas then
2812 HFFramesAuth.LoginUI.Username:SetText(username)
2813 HFFramesAuth.LoginUI.Password:SetText(pas)
2814 HFAuth()
2815 end
2816 end
2817 if lb then
2818 RUN_MACRO_TEXT = RunMacroText
2819 RunMacroText = function(...) lb.Unlock(RUN_MACRO_TEXT, ...) end
2820 end
2821
2822 SLASH_AUTHCMD1 = '/AUTH'
2823 SlashCmdList['AUTHCMD'] = AUTHCMD
2824 HF_AuthUI()
2825 base64='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
2826 function enc(data)
2827 return ((data:gsub('.', function(x)
2828 local r,base64='',x:byte()
2829 for i=8,1,-1 do r=r..(base64%2^i-base64%2^(i-1)>0 and '1' or '0') end
2830 return r;
2831 end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
2832 if (#x < 6) then return '' end
2833 local c=0
2834 for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
2835 return base64:sub(c+1,c+1)
2836 end)..({ '', '==', '=' })[#data%3+1])
2837 end
2838 function dec(data)
2839 data = string.gsub(data, '[^'..base64..'=]', '')
2840 return (data:gsub('.', function(x)
2841 if (x == '=') then return '' end
2842 local r,f='',(base64:find(x)-1)
2843 for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
2844 return r;
2845 end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
2846 if (#x ~= 8) then return '' end
2847 local c=0
2848 for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
2849 return string.char(c)
2850 end))
2851 end
2852 function num2hex(num)
2853 local hexstr = '0123456789abcdef'
2854 local s = ''
2855 while num > 0 do
2856 local mod = math.fmod(num, 16)
2857 s = string.sub(hexstr, mod+1, mod+1) .. s
2858 num = math.floor(num / 16)
2859 end
2860 if s == '' then s = '0' end
2861 return s
2862 end
2863 function str2hex(str)
2864 local hex = ''
2865 while #str > 0 do
2866 local hb = num2hex(string.byte(str, 1, 1))
2867 if #hb < 2 then hb = '0' .. hb end
2868 hex = hex .. hb
2869 str = string.sub(str, 2)
2870 end
2871 return hex
2872 end
2873 json = { _version = "0.1.2" }
2874 local encode
2875 local escape_char_map = {
2876 [ "\\" ] = "\\\\",
2877 [ "\"" ] = "\\\"",
2878 [ "\b" ] = "\\b",
2879 [ "\f" ] = "\\f",
2880 [ "\n" ] = "\\n",
2881 [ "\r" ] = "\\r",
2882 [ "\t" ] = "\\t",
2883 }
2884 local escape_char_map_inv = { [ "\\/" ] = "/" }
2885 for k, v in pairs(escape_char_map) do
2886 escape_char_map_inv[v] = k
2887 end
2888 local function escape_char(c)
2889 return escape_char_map[c] or string.format("\\u%04x", c:byte())
2890 end
2891 local function encode_nil(val)
2892 return "null"
2893 end
2894 local function encode_table(val, stack)
2895 local res = {}
2896 stack = stack or {}
2897 if stack[val] then error("circular reference") end
2898 stack[val] = true
2899 if rawget(val, 1) ~= nil or next(val) == nil then
2900 local n = 0
2901 for k in pairs(val) do
2902 if type(k) ~= "number" then
2903 error("invalid table: mixed or invalid key types")
2904 end
2905 n = n + 1
2906 end
2907 if n ~= #val then
2908 error("invalid table: sparse array")
2909 end
2910 for i, v in ipairs(val) do
2911 table.insert(res, encode(v, stack))
2912 end
2913 stack[val] = nil
2914 return "[" .. table.concat(res, ",") .. "]"
2915
2916 else
2917 for k, v in pairs(val) do
2918 if type(k) ~= "string" then
2919 error("invalid table: mixed or invalid key types")
2920 end
2921 table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
2922 end
2923 stack[val] = nil
2924 return "{" .. table.concat(res, ",") .. "}"
2925 end
2926 end
2927 local function encode_string(val)
2928 return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"'
2929 end
2930 local function encode_number(val)
2931 if val ~= val or val <= -math.huge or val >= math.huge then
2932 error("unexpected number value '" .. tostring(val) .. "'")
2933 end
2934 return string.format("%.14g", val)
2935 end
2936 local type_func_map = {
2937 [ "nil" ] = encode_nil,
2938 [ "table" ] = encode_table,
2939 [ "string" ] = encode_string,
2940 [ "number" ] = encode_number,
2941 [ "boolean" ] = tostring,
2942 }
2943 encode = function(val, stack)
2944 local t = type(val)
2945 local f = type_func_map[t]
2946 if f then
2947 return f(val, stack)
2948 end
2949 error("unexpected type '" .. t .. "'")
2950 end
2951 function json.encode(val)
2952 return ( encode(val) )
2953 end
2954 local parse
2955 local function create_set(...)
2956 local res = {}
2957 for i = 1, select("#", ...) do
2958 res[ select(i, ...) ] = true
2959 end
2960 return res
2961 end
2962 local space_chars = create_set(" ", "\t", "\r", "\n")
2963 local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",")
2964 local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u")
2965 local literals = create_set("true", "false", "null")
2966 local literal_map = {
2967 [ "true" ] = true,
2968 [ "false" ] = false,
2969 [ "null" ] = nil,
2970 }
2971 local function next_char(str, idx, set, negate)
2972 for i = idx, #str do
2973 if set[str:sub(i, i)] ~= negate then
2974 return i
2975 end
2976 end
2977 return #str + 1
2978 end
2979 local function decode_error(str, idx, msg)
2980 local line_count = 1
2981 local col_count = 1
2982 for i = 1, idx - 1 do
2983 col_count = col_count + 1
2984 if str:sub(i, i) == "\n" then
2985 line_count = line_count + 1
2986 col_count = 1
2987 end
2988 end
2989 error( string.format("%s at line %d col %d", msg, line_count, col_count) )
2990 end
2991 local function codepoint_to_utf8(n)
2992 local f = math.floor
2993 if n <= 0x7f then
2994 return string.char(n)
2995 elseif n <= 0x7ff then
2996 return string.char(f(n / 64) + 192, n % 64 + 128)
2997 elseif n <= 0xffff then
2998 return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128)
2999 elseif n <= 0x10ffff then
3000 return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128,
3001 f(n % 4096 / 64) + 128, n % 64 + 128)
3002 end
3003 error( string.format("invalid unicode codepoint '%x'", n) )
3004 end
3005 local function parse_unicode_escape(s)
3006 local n1 = tonumber( s:sub(3, 6), 16 )
3007 local n2 = tonumber( s:sub(9, 12), 16 )
3008 if n2 then
3009 return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000)
3010 else
3011 return codepoint_to_utf8(n1)
3012 end
3013 end
3014 local function parse_string(str, i)
3015 local has_unicode_escape = false
3016 local has_surrogate_escape = false
3017 local has_escape = false
3018 local last
3019 for j = i + 1, #str do
3020 local x = str:byte(j)
3021 if x < 32 then
3022 decode_error(str, j, "control character in string")
3023 end
3024 if last == 92 then
3025 if x == 117 then
3026 local hex = str:sub(j + 1, j + 5)
3027 if not hex:find("%x%x%x%x") then
3028 decode_error(str, j, "invalid unicode escape in string")
3029 end
3030 if hex:find("^[dD][89aAbB]") then
3031 has_surrogate_escape = true
3032 else
3033 has_unicode_escape = true
3034 end
3035 else
3036 local c = string.char(x)
3037 if not escape_chars[c] then
3038 decode_error(str, j, "invalid escape char '" .. c .. "' in string")
3039 end
3040 has_escape = true
3041 end
3042 last = nil
3043 elseif x == 34 then
3044 local s = str:sub(i + 1, j - 1)
3045 if has_surrogate_escape then
3046 s = s:gsub("\\u[dD][89aAbB]..\\u....", parse_unicode_escape)
3047 end
3048 if has_unicode_escape then
3049 s = s:gsub("\\u....", parse_unicode_escape)
3050 end
3051 if has_escape then
3052 s = s:gsub("\\.", escape_char_map_inv)
3053 end
3054 return s, j + 1
3055
3056 else
3057 last = x
3058 end
3059 end
3060 decode_error(str, i, "expected closing quote for string")
3061 end
3062 local function parse_number(str, i)
3063 local x = next_char(str, i, delim_chars)
3064 local s = str:sub(i, x - 1)
3065 local n = tonumber(s)
3066 if not n then
3067 decode_error(str, i, "invalid number '" .. s .. "'")
3068 end
3069 return n, x
3070 end
3071 local function parse_literal(str, i)
3072 local x = next_char(str, i, delim_chars)
3073 local word = str:sub(i, x - 1)
3074 if not literals[word] then
3075 decode_error(str, i, "invalid literal '" .. word .. "'")
3076 end
3077 return literal_map[word], x
3078 end
3079 local function parse_array(str, i)
3080 local res = {}
3081 local n = 1
3082 i = i + 1
3083 while 1 do
3084 local x
3085 i = next_char(str, i, space_chars, true)
3086 if str:sub(i, i) == "]" then
3087 i = i + 1
3088 break
3089 end
3090 x, i = parse(str, i)
3091 res[n] = x
3092 n = n + 1
3093 i = next_char(str, i, space_chars, true)
3094 local chr = str:sub(i, i)
3095 i = i + 1
3096 if chr == "]" then break end
3097 if chr ~= "," then decode_error(str, i, "expected ']' or ','") end
3098 end
3099 return res, i
3100 end
3101 local function parse_object(str, i)
3102 local res = {}
3103 i = i + 1
3104 while 1 do
3105 local key, val
3106 i = next_char(str, i, space_chars, true)
3107 if str:sub(i, i) == "}" then
3108 i = i + 1
3109 break
3110 end
3111 if str:sub(i, i) ~= '"' then
3112 decode_error(str, i, "expected string for key")
3113 end
3114 key, i = parse(str, i)
3115 i = next_char(str, i, space_chars, true)
3116 if str:sub(i, i) ~= ":" then
3117 decode_error(str, i, "expected ':' after key")
3118 end
3119 i = next_char(str, i + 1, space_chars, true)
3120 val, i = parse(str, i)
3121 res[key] = val
3122 i = next_char(str, i, space_chars, true)
3123 local chr = str:sub(i, i)
3124 i = i + 1
3125 if chr == "}" then break end
3126 if chr ~= "," then decode_error(str, i, "expected '}' or ','") end
3127 end
3128 return res, i
3129 end
3130 local char_func_map = {
3131 [ '"' ] = parse_string,
3132 [ "0" ] = parse_number,
3133 [ "1" ] = parse_number,
3134 [ "2" ] = parse_number,
3135 [ "3" ] = parse_number,
3136 [ "4" ] = parse_number,
3137 [ "5" ] = parse_number,
3138 [ "6" ] = parse_number,
3139 [ "7" ] = parse_number,
3140 [ "8" ] = parse_number,
3141 [ "9" ] = parse_number,
3142 [ "-" ] = parse_number,
3143 [ "t" ] = parse_literal,
3144 [ "f" ] = parse_literal,
3145 [ "n" ] = parse_literal,
3146 [ "[" ] = parse_array,
3147 [ "{" ] = parse_object,
3148 }
3149 parse = function(str, idx)
3150 local chr = str:sub(idx, idx)
3151 local f = char_func_map[chr]
3152 if f then
3153 return f(str, idx)
3154 end
3155 decode_error(str, idx, "unexpected character '" .. chr .. "'")
3156 end
3157 function json.decode(str)
3158 if type(str) ~= "string" then
3159 error("expected argument of type string, got " .. type(str))
3160 end
3161 local res, idx = parse(str, next_char(str, 1, space_chars, true))
3162 idx = next_char(str, idx, space_chars, true)
3163 if idx <= #str then
3164 decode_error(str, idx, "trailing garbage")
3165 end
3166 return res
3167 end
3168
3169 userdata = {}
3170
3171
3172 if HFRequest then
3173 print("You likely already launched the login UI once. Please reload UI.")
3174 Should_Fail = true
3175 return
3176 end
3177
3178 local function isEWT()
3179 if GetOffset then
3180 local ofs = GetOffset("s_accountName")
3181 local test = GetOffset("test")
3182 if ofs > 0 and ofs < 2147483647 and EWT.configuredBaits and
3183 not EWT.isDebug and test == -1 then return true end
3184 end
3185 end
3186
3187 if not isEWT() then ForceQuit() end
3188
3189 HFPlatform = "EWT"
3190
3191 local functions_to_protect = {"HFRequest", "HFDoAuth", "HFNeedAuth"}
3192 local protectedFunctions = {}
3193
3194 local function build_global_functions()
3195 HFRequest = function(data)
3196 SendHTTPRequest("https://scriptvirt.com/auth/auth2.php?d=" .. data, nil,
3197 function(body, code, req, res, err)
3198 if HFLoaded then
3199 local num = tonumber(body)
3200 local t = tonumber(GetReqTime())
3201 if not num or not t then ForceQuit() end
3202 local tmp = math.floor(t)
3203 local tmp2 = math.floor(tmp / 3)
3204 local tmp3 = math.floor(tmp / 4)
3205 local tmp4 = tmp2 + tmp3 + 1337
3206 if num ~= tmp4 then ForceQuit() end
3207 return
3208 end
3209 HFFramesAuth.StatusUI:Show()
3210 if err and err ~= " " and err ~= "" then
3211 HFFramesAuth.StatusUI.Text:SetText("Error: " .. err)
3212 return
3213 end
3214 if not code then
3215 HFFramesAuth.StatusUI.Text:SetText("Network Error")
3216 return
3217 end
3218 if code == "200" then
3219 HFFramesAuth.StatusUI.Text:SetText("Status: Loading")
3220 RunScript(body)
3221 HFFramesAuth.StatusUI.Text:SetText("Status: Success")
3222 HFFramesAuth.StatusUI:Hide()
3223 HFLoaded = true
3224 HF_OnLoad()
3225 end
3226 if code == "401" then
3227 HFFramesAuth.StatusUI.Text:SetText("Login failed! Check username and password or register at www.ScriptVirt.com")
3228 end
3229 if code == "403" then
3230 HFFramesAuth.StatusUI.Text:SetText("Please purchase a subscription at www.ScriptVirt.com")
3231 end
3232 if code == "409" then
3233 HFFramesAuth.StatusUI.Text:SetText("Your account has been locked out. Please wait 15 min before next reconnect attempt")
3234 end
3235 if code == "500" then
3236 HFFramesAuth.StatusUI.Text:SetText("Server Error")
3237 end
3238 end
3239 , "")
3240 end
3241 protectedFunctions["HFRequest"] = HFRequest
3242 HFDoAuth = function()
3243 HFFramesAuth.StatusUI.Text:SetText("Status: Verifying")
3244 local tbl = {}
3245 tbl["a" .. tostring(math.random(0, 10000))] = tostring(math.random(0, 10000))
3246 tbl["aa" .. tostring(math.random(0, 10000))] = tostring(math.random(0, 10000))
3247 tbl["u"] = userdata["u"]
3248 tbl["p"] = userdata["p"]
3249 tbl["c"] = userdata["c"]
3250 tbl["pl"] = HFPlatform
3251 tbl["g"] = "BFA"
3252 tbl["tk"] = HFToken or ""
3253 local tt = GetTime()
3254 tbl["t"] = tt
3255 userdata["t"] = tt
3256 tbl["z" .. tostring(math.random(0, 10000))] = tostring(math.random(0, 10000))
3257 tbl["zz" .. tostring(math.random(0, 10000))] = tostring(math.random(0, 10000))
3258 tbl[tostring(math.random(0, 10000))] = tostring(math.random(0, 10000))
3259 HFRequest(str2hex(enc(json.encode(tbl))))
3260 end
3261 protectedFunctions["HFDoAuth"] = HFDoAuth
3262 HFNeedAuth = function()
3263 return not userdata["t"] or GetTime() - userdata["t"] > 5 * 60
3264 end
3265 protectedFunctions["HFNeedAuth"] = HFNeedAuth
3266 end
3267
3268 local function protect_global_functions()
3269 for _, routine in ipairs(functions_to_protect) do
3270 if _G[routine] ~= protectedFunctions[routine] then
3271 UnloadEWT( "You are not allowed to hook HandsFree global functions.")
3272 end
3273 end
3274 end
3275
3276 build_global_functions()
3277 protect_global_functions()
3278
3279 local f = CreateFrame("Frame")
3280 f:SetScript("OnUpdate", protect_global_functions)"]:594:
3281 [string "local GetReqTime = function() return userda..."]:571
3282 [string "EWT = {}
3283
3284 local version, internalVersion, date, uiVersion = GetBuildInfo()
3285 EWT.wowBuild = tonumber(internalVersion)
3286 if EWT.wowBuild == nil then
3287 EWT.wowBuild = tonumber(uiVersion)
3288 EWT.isClassic = string.find(date, "1.13") == 1
3289 EWT.is83 = string.find(date, "8.3") == 1
3290 else
3291 EWT.isClassic = string.find(version, "1.13") == 1
3292 EWT.is83 = string.find(version, "8.3") == 1
3293 end
3294 EWT.is73 = false
3295 EWT.isPrivate = false
3296 EWT.mode = 1
3297 EWT.isDebug = false
3298 if EWT.wowBuild then
3299 EWT.is73 = EWT.wowBuild >= 24920
3300 EWT.is80 = EWT.wowBuild >= 27165
3301 end
3302
3303 if _G == nil then
3304 _G = getfenv()
3305 end
3306
3307 function EWT.print(msg)
3308 local str = 'EWT | ' .. msg
3309 if EWT.wowBuild < 12340 then
3310 DEFAULT_CHAT_FRAME:AddMessage(str)
3311 else
3312 print(str)
3313 end
3314 end
3315
3316 EWT.debug = false
3317 local function eprint(msg)
3318 if EWT.debug == true then
3319 EWT.print(msg)
3320 end
3321 end
3322
3323 if EWT.wowBuild ~= nil and EWT.wowBuild < 12340 and DEFAULT_CHAT_FRAME ~= nil then
3324
3325 function print(msg) DEFAULT_CHAT_FRAME:AddMessage(tostring(msg)) end
3326
3327 end
3328
3329 if AccountLoginUI == nil and AccountLogin ~= nil then
3330 AccountLoginUI = AccountLogin.UI
3331 end
3332
3333 if AccountLogin ~= nil then
3334 if AccountLoginPasswordEdit == nil then
3335 AccountLoginPasswordEdit = AccountLogin.UI.PasswordEditBox
3336 end
3337 if AccountLoginAccountEdit == nil then
3338 AccountLoginAccountEdit = AccountLogin.UI.AccountEditBox
3339 end
3340 end
3341
3342 -- ewtMod is needed because of WoW 1.12.1 which doesnt have % operator
3343 local function ewtMod (a, b)
3344 return a - math.floor(a / b) * b
3345 end
3346
3347 local GetSessionVariable_Original = GetSessionVariable
3348 function GetSessionVariable(var)
3349 if var == "loginPw" or var == "loginAcc" then
3350 error("Forbidden session variable")
3351 else
3352 return GetSessionVariable(var)
3353 end
3354 end
3355
3356 EWT.enterWorld = true
3357 EWT.loginLimit = 100
3358 local loginCount = 0
3359 local loginCount2 = 0
3360 local clickedRealm = 0
3361 local chosenRealm = nil
3362 local chosenAccount = nil
3363 function EWT.login()
3364 -- GlueDialog shown when 'Connecting' or 'You have been disconnected'. It blocks all input.
3365 -- UIParent always present. WorldFrame only in the game world.
3366 -- AccountLoginUI > RealmListUI > CharacterSelectUI > WorldFrame
3367 if AccountLoginUI and AccountLoginUI:IsVisible() and AccountLoginPasswordEdit then
3368 local loginPw = GetSessionVariable_Original("loginPw")
3369 local loginName = GetSessionVariable_Original("loginName")
3370 local loginAcc = GetSessionVariable_Original("loginAcc")
3371 if loginName ~= nil and loginName ~= "" then
3372 AccountLoginAccountEdit:SetText(loginName)
3373 else
3374 loginName = GetSavedAccountName()
3375 end
3376 if AccountLoginUI.WoWAccountSelectDialog:IsShown() then
3377 C_Login.SelectGameAccount(loginAcc);
3378 end
3379 AccountLoginPasswordEdit:SetText(loginPw)
3380 clickedRealm = 0
3381 loginCount = 0
3382 loginCount2 = loginCount2 + 1
3383 -- Spam on private servers
3384 if (EWT.isPrivate == false and loginCount2 == EWT.loginLimit) or EWT.isPrivate == true then
3385 if DefaultServerLogin then
3386 DefaultServerLogin(loginName, loginPw)
3387 else
3388 C_Login.Login(loginName, AccountLoginPasswordEdit)
3389 if EWT.isPrivate == false and AccountLoginDropDown:IsShown() then
3390 C_Login.SelectGameAccount(GlueDropDownMenu_GetSelectedValue(AccountLoginDropDown))
3391 end
3392 end
3393 end
3394 return 1
3395 end
3396 if chosenRealm == nil then
3397 if GetServerName then
3398 chosenRealm = GetServerName()
3399 end
3400 if GetRealmName then
3401 chosenRealm = GetRealmName()
3402 end
3403 if chosenRealm then
3404 SetSessionVariable('realmName', chosenRealm)
3405 end
3406 end
3407 if RealmListOkButton and RealmListOkButton:IsVisible() then
3408 if RealmListOkButton:IsEnabled() then
3409 clickedRealm = 1
3410 RealmListOkButton:Click()
3411 RealmListOkButton:Disable()
3412 else
3413 if clickedRealm == 0 then
3414 local realmName = GetSessionVariable("realmName")
3415 if realmName then
3416 RealmList.selectedRealm, RealmList.selectedCategory = RealmList_GetInfoFromName(realmName);
3417 RealmList_UpdateOKButton()
3418 end
3419 -- RealmList_Update();
3420 -- RealmListOkButton:SetEnabled(true)
3421 -- RealmListOkButton:Click()
3422 end
3423 end
3424 return 2
3425 end
3426 if PromotionFrame and PromotionFrame:IsVisible() then
3427 PromotionFrame_Hide()
3428 end
3429 if CharSelectEnterWorldButton and CharSelectEnterWorldButton:IsVisible() and CharSelectEnterWorldButton:IsEnabled() then
3430 loginCount2 = 0
3431 loginCount = loginCount + 1
3432 if loginCount == EWT.loginLimit and EWT.enterWorld == true then
3433 CharSelectEnterWorldButton:Click()
3434 CharSelectEnterWorldButton:Disable()
3435 end
3436 return 3
3437 end
3438 return 0
3439 end
3440
3441 local function RMT(text)
3442 local cmd = "." .. text
3443 eprint(cmd)
3444 RunMacroText(cmd)
3445 end
3446
3447 function EWT.flash()
3448 if EWT.wowBuild < 20779 then
3449 RMT("flash")
3450 elseif FlashClientIcon then
3451 FlashClientIcon()
3452 end
3453 end
3454
3455 -- if not UseItemByName then
3456 if EWT.wowBuild ~= nil and EWT.wowBuild <= 8606 then
3457
3458 function ItemLinkToName(link)
3459 return gsub(link, "^.*%[(.*)%].*$", "%1");
3460 end
3461
3462 function FindItem(item)
3463 if (not item) then return; end
3464 item = string.lower(ItemLinkToName(item));
3465 local link;
3466 for i = 1, 23 do
3467 link = GetInventoryItemLink("player", i);
3468 if (link) then
3469 if (item == string.lower(ItemLinkToName(link)))then
3470 return i, nil, GetInventoryItemTexture('player', i), GetInventoryItemCount('player', i);
3471 end
3472 end
3473 end
3474 local count, bag, slot, texture;
3475 local totalcount = 0;
3476 for i = 0, NUM_BAG_FRAMES do
3477 for j = 1, MAX_CONTAINER_ITEMS do
3478 link = GetContainerItemLink(i, j);
3479 if (link) then
3480 if (item == string.lower(ItemLinkToName(link))) then
3481 bag, slot = i, j;
3482 texture, count = GetContainerItemInfo(i, j);
3483 totalcount = totalcount + count;
3484 end
3485 end
3486 end
3487 end
3488 return bag, slot, texture, totalcount;
3489 end
3490
3491 function UseItemByName(item)
3492 local bag, slot = FindItem(item);
3493 if (not bag) then return; end;
3494 if (slot) then
3495 UseContainerItem(bag, slot); -- use, equip item in bag
3496 return bag, slot;
3497 else
3498 UseInventoryItem(bag); -- unequip from body
3499 return bag;
3500 end
3501 end
3502
3503 end
3504
3505 local function useItem(item)
3506 if EWT.wowBuild < 8606 then
3507 UseItemByName(item)
3508 return true
3509 end
3510 -- if item can be used and not on cooldown and the player isnt casting
3511 if IsUsableItem(item) and not (UnitCastingInfo("player") or UnitChannelInfo("player")) and GetItemCooldown(item) == 0 then
3512 UseItemByName(item)
3513 return true
3514 end
3515 return false
3516 end
3517
3518 local function getNumFreeSlots()
3519 local freeSlots = 0
3520 for bag = 0, 4 do
3521 freeSlots = freeSlots + GetContainerNumFreeSlots(bag)
3522 end
3523 return freeSlots
3524 end
3525
3526 local function IsItemInBags(search)
3527 for bag = 0, 4 do
3528 for slot = 1, GetContainerNumSlots(bag) do
3529 local item = GetContainerItemLink(bag, slot)
3530 if item and item:find(search) then
3531 return true
3532 end
3533 end
3534 end
3535 return false
3536 end
3537
3538 EWT.configuredBaits = {}
3539
3540 local gutfish = {111671, 111672, 111673, 111674, 111675, 111676, 111601, 118566, 111664, 111663, 111669, 111666, 111667, 111668, 111665, 111595, 118565, 111589, 111658, 111652, 111650, 111656, 111651, 111659, 111662, 118564, 111670}
3541
3542 function EWT.autoGut()
3543 eprint('autoGutting')
3544
3545 if EWT.wowBuild <= 18414 then return end
3546
3547 for i, v in pairs(gutfish) do
3548 if useItem(v) then return end
3549 end
3550 end
3551
3552 -- Combat stuff | Auto-Interrupt
3553
3554 local function info(spell)
3555 return GetSpellInfo(spell)
3556 end
3557
3558 local function cast(spell)
3559 if type(spell) == "string" and tonumber(spell) == nil then
3560 return CastSpellByName(spell)
3561 else
3562 return CastSpellByName(info(spell))
3563 end
3564 end
3565
3566 local function AutoInterrupt(spellName, yourTarget)
3567 if spellName ~= nil then
3568 local name = UnitCastingInfo(yourTarget) or UnitChannelInfo(yourTarget)
3569 local Sname, subText, text, texture, sTime, eTime, isTradeSkill, notInterruptible = UnitCastingInfo("target");
3570
3571 if eTime then
3572 finish = (eTime / 1000 - GetTime())
3573 end
3574
3575 local notInterruptible = select(9, UnitCastingInfo(yourTarget)) or select(8, UnitChannelInfo(yourTarget))
3576 if UnitExists(yourTarget) and not UnitIsDead(yourTarget) and UnitCanAttack("player", yourTarget) and name and not notInterruptible and finish < 1 then
3577 cast(spellName)
3578 end
3579 end
3580 end
3581
3582 local initProjections = 0
3583 function EWT.Projections(enable)
3584 if enable ~= nil and type(enable) == "number" then
3585 initProjections = enable
3586 -- RMT("unlocklua " .. enable)
3587 end
3588 end
3589
3590 local OBJECTTRACKER = {}
3591 local ewtFrame = CreateFrame("Frame")
3592 local apiFrame = CreateFrame("Frame")
3593 ewtFrame:SetScript("OnUpdate", function (self, event, addon)
3594
3595 if initProjections == 1 then
3596 eprint("projecting")
3597 local sWidth, sHeight = GetWoWWindow()
3598 SetDrawColor(1, 1, 1, 1) -- white
3599 Draw2DText(sWidth * 0.5, sHeight * 0.5, 'THIS IS A TEST')
3600 local totalObjects = GetObjectCount()
3601 for i = 1, totalObjects do
3602 local object = ObjectWithIndex(i)
3603 OBJECTTRACKER[object] = CanTrackObject(object)
3604 end
3605 local camX, camY, camZ = GetCameraPosition()
3606 for i, v in pairs(OBJECTTRACKER) do
3607 if v then -- Bool: if the object can be tracked or not
3608 local targetX, targetY, targetZ = ObjectPosition(i)
3609 if IsInFront(targetX, targetY, targetZ) then
3610 if ObjectIsUnit(i) then
3611 local reaction = UnitReaction("player", i)
3612 if reaction then
3613 if reaction > 4 then
3614 if UnitIsPlayer(i) then
3615 SetDrawColor(0, 0, 1, 1) -- blue
3616 else
3617 SetDrawColor(0, 1, 0, 1) -- green
3618 end
3619 elseif reaction == 4 then
3620 SetDrawColor(1, 1, 0, 1) -- yellow
3621 elseif reaction < 4 then
3622 SetDrawColor(1, 0, 0, 1) -- red
3623 end
3624 else
3625 SetDrawColor(1, 1, 1, 1) -- white
3626 end
3627 else
3628 SetDrawColor(1, 1, 1, 1) -- white
3629 end
3630 local player2DX, player2DY, playerInFront = WorldToScreen_Original(ObjectPosition("player"))
3631 local target2DX, target2DY, targetInFront = WorldToScreen_Original(targetX, targetY, targetZ)
3632 Draw2DLine(player2DX * sWidth, player2DY * sHeight, target2DX * sWidth, target2DY * sHeight)
3633 end
3634 end
3635 end
3636 end
3637
3638 -- if GetSessionVariable ~= nil then
3639 -- local interruptSpell = GetSessionVariable("interruptSpell")
3640 -- if interruptSpell and interruptSpell ~= 0 then
3641 -- eprint('interrupting ' .. interruptSpell)
3642 -- AutoInterrupt(tonumber(interruptSpell), "target")
3643 -- end
3644 -- end
3645
3646 end)
3647
3648 ewtFrame:SetScript("OnEvent", function(self, event, addon, ...)
3649 eprint('OnEvent')
3650 local acceptLFG = false
3651 if IsHackEnabled then
3652 acceptLFG = IsHackEnabled("AutoAccept")
3653 end
3654 if event == "UPDATE_BATTLEFIELD_STATUS" then
3655 local index
3656 -- remember this caused infinite loop on Warmane 3.3.5
3657 for index = 1, 2 do -- MAX_BATTLEFIELD_QUEUES
3658 local status = GetBattlefieldStatus(index)
3659 if status == "confirm" then
3660 EWT.flash()
3661 if acceptLFG == true then
3662 AcceptProposal()
3663 AcceptBattlefieldPort(index, 1)
3664 end
3665 end
3666 end
3667 elseif event == "LFG_PROPOSAL_SHOW" then
3668 EWT.flash()
3669 if acceptLFG == true then
3670 AcceptProposal()
3671 end
3672 end
3673 end)
3674
3675 local trEvents = {"UPDATE_BATTLEFIELD_STATUS"}
3676
3677 if EWT.wowBuild and EWT.wowBuild > 8606 and EWT.isClassic == false then
3678 tinsert(trEvents, "LFG_PROPOSAL_SHOW")
3679 end
3680
3681 for i, v in pairs(trEvents) do
3682 ewtFrame:RegisterEvent(v)
3683 end
3684
3685 EasyWoWToolbox = 1
3686
3687 -- /script print(GetMouseFocus():GetName())
3688 -- /script print(GetMouseFocus():GetVerticalScroll())
3689
3690 -- SLASH_RELOADEWT1 = "/reloadewt";
3691 -- SlashCmdList["RELOADEWT"] = function (Message, EditBox)
3692 -- RMT("reload");
3693 -- end
3694
3695 -- SLASH_UNLOADEWT1 = "/unloadewt";
3696 -- SlashCmdList["UNLOADEWT"] = function (Message, EditBox)
3697 -- RMT("unload");
3698 -- end
3699
3700 -- API
3701
3702 -- Thanks Journey/Starship for storing Lua in the .dll :D
3703 function EWT.EnableMorph()
3704
3705 -- Extends item click functionality.
3706
3707 local invTypeMap = {
3708 INVTYPE_HEAD = 1,
3709 INVTYPE_SHOULDER = 3,
3710 INVTYPE_BODY = 4,
3711 INVTYPE_CHEST = 5,
3712 INVTYPE_ROBE = 5,
3713 INVTYPE_WAIST = 6,
3714 INVTYPE_LEGS = 7,
3715 INVTYPE_FEET = 8,
3716 INVTYPE_WRIST = 9,
3717 INVTYPE_HAND = 10,
3718 INVTYPE_CLOAK = 15,
3719 INVTYPE_WEAPON = 16,
3720 INVTYPE_SHIELD = 17,
3721 INVTYPE_2HWEAPON = 16,
3722 INVTYPE_WEAPONMAINHAND = 16,
3723 INVTYPE_WEAPONOFFHAND = 17,
3724 INVTYPE_HOLDABLE = 17,
3725 INVTYPE_RANGED = 16,
3726 INVTYPE_RANGEDRIGHT = 16,
3727 INVTYPE_TABARD = 19,
3728 }
3729
3730 local function findItemAppearanceModID(itemID, appearanceVisualID)
3731 -- There is definitely a much better way of doing this.
3732 if appearanceVisualID == nil then
3733 appearanceVisualID = C_TransmogCollection.GetItemInfo(itemID)
3734 end
3735 if appearanceVisualID ~= nil then
3736 if type(itemID) == "string" then
3737 itemID = GetItemInfoInstant(itemID)
3738 end
3739 for i = 0, 9 do
3740 if appearanceVisualID == C_TransmogCollection.GetItemInfo(itemID, i) then
3741 return i
3742 end
3743 end
3744 end
3745 return 0
3746 end
3747
3748 local oldHandleModifiedItemClick = HandleModifiedItemClick
3749 function HandleModifiedItemClick(link)
3750 if link and IsDressableItem(link) and IsLeftAltKeyDown() and UpdateModel then
3751 local _, itemID = strsplit(":", link)
3752 local _, _, _, equipLoc = GetItemInfoInstant(itemID)
3753 if invTypeMap[equipLoc] then
3754 SetVisibleItem("player", invTypeMap[equipLoc], itemID, findItemAppearanceModID(link, nil))
3755 UpdateModel("player")
3756 -- PlaySound("UI_Transmog_ItemClick")
3757 end
3758 return true
3759 end
3760 return oldHandleModifiedItemClick(link)
3761 end
3762
3763 -- Extends mount journal functionality.
3764
3765 -- if not IsAddOnLoaded("Blizzard_Collections") then
3766 -- LoadAddOn("Blizzard_Collections")
3767 -- end
3768
3769 local function MountHook(self, button)
3770 if not IsLeftAltKeyDown() or not SetMountDisplayID then return end
3771
3772 local displayID = C_MountJournal.GetMountInfoExtraByID(MountJournal.selectedMountID)
3773 SetMountDisplayID("player", displayID)
3774 -- PlaySound("UI_Transmog_ItemClick")
3775 end
3776
3777 local itemFrameKey = "ItemsCollectionFrame"
3778 local is720 = EWT.wowBuild >= 24015
3779
3780 local function morphToWardrobeItem(self, button)
3781 if not IsLeftAltKeyDown() or not UpdateModel then return end
3782
3783 local slot, itemFrame, mogType
3784 if is720 then
3785 itemFrame = WardrobeCollectionFrame[itemFrameKey]
3786 slot = GetInventorySlotInfo(itemFrame:GetActiveSlot())
3787 mogType = itemFrame.transmogType
3788 else
3789 slot = GetInventorySlotInfo(WardrobeCollectionFrame.activeSlot)
3790 mogType = WardrobeCollectionFrame.transmogType
3791 end
3792
3793 if (mogType == LE_TRANSMOG_TYPE_APPEARANCE) then
3794 local itemLink
3795 if is720 then
3796 itemLink = select(6, C_TransmogCollection.GetAppearanceSourceInfo(itemFrame:GetAnAppearanceSourceFromVisual(self.visualInfo.visualID)))
3797 else
3798 itemLink = select(6, C_TransmogCollection.GetAppearanceSourceInfo(WardrobeCollectionFrame_GetAnAppearanceSourceFromVisual(self.visualInfo.visualID)))
3799 end
3800 local itemID = GetItemInfoInstant(itemLink)
3801 SetVisibleItem("player", slot, itemID, findItemAppearanceModID(itemID, self.visualInfo.visualID))
3802 UpdateModel("player")
3803 elseif (mogType == LE_TRANSMOG_TYPE_ILLUSION) then
3804 SetVisibleEnchant("player", slot, self.visualInfo.visualID)
3805 UpdateModel("player")
3806 end
3807 -- PlaySound("UI_Transmog_ItemClick")
3808 end
3809
3810 EWT.appliedHooks = false;
3811 function EWT.applyMorphHooks()
3812
3813 if not IsAddOnLoaded("Blizzard_Collections") or EWT.appliedHooks then return end
3814
3815 EWT.appliedHooks = true
3816
3817 if EWT.wowBuild > 22594 and EWT.wowBuild < 24015 then
3818
3819 itemFrameKey = "ModelsFrame"
3820 MountJournal.MountDisplay.ModelFrame:HookScript("OnMouseUp", MountHook)
3821
3822 end
3823
3824 if EWT.wowBuild >= 24015 then
3825
3826 MountJournal.MountDisplay.ModelScene:HookScript("OnMouseUp", MountHook)
3827
3828 -- Extends wardrobe functionality.
3829
3830 WardrobeCollectionFrame.SetsCollectionFrame.Model:HookScript("OnMouseUp", function(self, button)
3831 if not IsLeftAltKeyDown() or not UpdateModel then return end
3832
3833 local setID = WardrobeCollectionFrame.SetsCollectionFrame:GetSelectedSetID()
3834 local itemModID = nil
3835 for i, slot in pairs(invTypeMap) do
3836 local sourceIDs = C_TransmogSets.GetSourceIDsForSlot(setID, slot)
3837 if sourceIDs[1] then
3838 local itemLink = select(6, C_TransmogCollection.GetAppearanceSourceInfo(sourceIDs[1]))
3839 local itemID = GetItemInfoInstant(itemLink)
3840 if itemModID == nil then
3841 itemModID = findItemAppearanceModID(itemLink, nil)
3842 end
3843 SetVisibleItem("player", slot, itemID, itemModID)
3844 end
3845 end
3846 UpdateModel("player")
3847 -- PlaySound("UI_Transmog_Apply")
3848 end)
3849
3850 end
3851
3852 WardrobeCollectionFrame[itemFrameKey].ModelR1C1:HookScript("OnMouseUp", morphToWardrobeItem)
3853 WardrobeCollectionFrame[itemFrameKey].ModelR1C2:HookScript("OnMouseUp", morphToWardrobeItem)
3854 WardrobeCollectionFrame[itemFrameKey].ModelR1C3:HookScript("OnMouseUp", morphToWardrobeItem)
3855 WardrobeCollectionFrame[itemFrameKey].ModelR1C4:HookScript("OnMouseUp", morphToWardrobeItem)
3856 WardrobeCollectionFrame[itemFrameKey].ModelR1C5:HookScript("OnMouseUp", morphToWardrobeItem)
3857 WardrobeCollectionFrame[itemFrameKey].ModelR1C6:HookScript("OnMouseUp", morphToWardrobeItem)
3858
3859 WardrobeCollectionFrame[itemFrameKey].ModelR2C1:HookScript("OnMouseUp", morphToWardrobeItem)
3860 WardrobeCollectionFrame[itemFrameKey].ModelR2C2:HookScript("OnMouseUp", morphToWardrobeItem)
3861 WardrobeCollectionFrame[itemFrameKey].ModelR2C3:HookScript("OnMouseUp", morphToWardrobeItem)
3862 WardrobeCollectionFrame[itemFrameKey].ModelR2C4:HookScript("OnMouseUp", morphToWardrobeItem)
3863 WardrobeCollectionFrame[itemFrameKey].ModelR2C5:HookScript("OnMouseUp", morphToWardrobeItem)
3864 WardrobeCollectionFrame[itemFrameKey].ModelR2C6:HookScript("OnMouseUp", morphToWardrobeItem)
3865
3866 WardrobeCollectionFrame[itemFrameKey].ModelR3C1:HookScript("OnMouseUp", morphToWardrobeItem)
3867 WardrobeCollectionFrame[itemFrameKey].ModelR3C2:HookScript("OnMouseUp", morphToWardrobeItem)
3868 WardrobeCollectionFrame[itemFrameKey].ModelR3C3:HookScript("OnMouseUp", morphToWardrobeItem)
3869 WardrobeCollectionFrame[itemFrameKey].ModelR3C4:HookScript("OnMouseUp", morphToWardrobeItem)
3870 WardrobeCollectionFrame[itemFrameKey].ModelR3C5:HookScript("OnMouseUp", morphToWardrobeItem)
3871 WardrobeCollectionFrame[itemFrameKey].ModelR3C6:HookScript("OnMouseUp", morphToWardrobeItem)
3872
3873 end
3874
3875 EWT.applyMorphHooks()
3876
3877 end -- end of EnableMorph
3878
3879 local UnlockedFunctions = {}
3880 local UnlockedNamespaces = {}
3881
3882 function EWT.EnableAPI()
3883 FireHack = true
3884
3885 ----- REMOVE BEGIN
3886
3887 if EWT.is73 then
3888
3889 EWT.oldSendText = ChatEdit_SendText
3890 function ChatEdit_SendText(editBox, addHistory)
3891 -- SAY, WHISPER, etc
3892 -- local type = editBox:GetAttribute("chatType");
3893 -- Raw text
3894 -- ChatEdit_ParseText(editBox, 1); -- this erases text for / commands
3895 local text = editBox:GetText();
3896 local ret = RunEWTCommand(text)
3897 if ret == false then
3898 EWT.oldSendText(editBox, addHistory)
3899 else
3900 ChatEdit_AddHistory(editBox)
3901 end
3902 end
3903
3904
3905 -- EWT.oldSendChatMessage = SendChatMessage
3906 -- function SendChatMessage (text, ...)
3907 -- if RunEWTCommand(text) == false then
3908 -- EWT.oldSendChatMessage(text, ...)
3909 -- end
3910 -- end
3911 -- EWT.oldBNSendWhisper = BNSendWhisper
3912 -- function BNSendWhisper (id, text, ...)
3913 -- if RunEWTCommand(text) == false then
3914 -- EWT.oldBNSendWhisper(id, text, ...)
3915 -- end
3916 -- end
3917
3918 local FunctionsToUnlock = {
3919 "AcceptProposal",
3920 "AcceptBattlefieldPort",
3921 "AscendStop",
3922 "AssistUnit",
3923 "AttackTarget",
3924 "CameraOrSelectOrMoveStart",
3925 "CameraOrSelectOrMoveStop",
3926 "CancelItemTempEnchantment",
3927 "CancelAuction",
3928 "CancelLogout",
3929 "CancelShapeshiftForm",
3930 "CancelSpellByName",
3931 "CancelUnitBuff",
3932 "CanInspect",
3933 "CanLootUnit",
3934 "CastPetAction",
3935 "CastShapeshiftForm",
3936 "CastSpell",
3937 "CastSpellByID",
3938 "CastSpellByName",
3939 "ClearFocus",
3940 "CheckInteractDistance",
3941 "ClearPartyAssignment",
3942 "ClearTarget",
3943 "ClickPosition",
3944 "ClosestUnitPosition",
3945 "DescendStop",
3946 "DestroyTotem",
3947 "DisableSpellAutocast",
3948 "DropItemOnUnit",
3949 "EnableSpellAutocast",
3950 "FocusUnit",
3951 "ForceQuit",
3952 "ForceLogout",
3953 "GetArenaOpponentSpec",
3954 "GetComboPoints",
3955 "GetGuildInfo",
3956 "GetMuteStatus",
3957 "GetPlayerInfoByGUID",
3958 "GetPlayerMapPosition",
3959 "GetRaidTargetIndex",
3960 "GetUnitSpeed",
3961 "GuildControlSetRank",
3962 "InteractUnit",
3963 "InviteUnit",
3964 "IsIgnoredOrMuted",
3965 "IsMuted",
3966 -- "issecure",
3967 "IsSpellInRange",
3968 "IsUnitOnQuest",
3969 "JoinArena",
3970 "JoinBattlefield",
3971 "JumpOrAscendStart",
3972 "LearnTalent",
3973 "Logout",
3974 "MoveAndSteerStart",
3975 "MoveAndSteerStop",
3976 "MoveBackwardStart",
3977 "MoveBackwardStop",
3978 "MoveForwardStart",
3979 "MoveForwardStop",
3980 "MusicPlayer_BackTrack",
3981 "MusicPlayer_NextTrack",
3982 "MusicPlayer_PlayPause",
3983 "MusicPlayer_VolumeDown",
3984 "MusicPlayer_VolumeUp",
3985 "NewGMTicket",
3986 "PetAggressiveMode",
3987 "PetAssistMode",
3988 "PetAttack",
3989 "PetDefensiveMode",
3990 "PetFollow",
3991 "PetMoveTo",
3992 "PetPassiveMode",
3993 "PetStopAttack",
3994 "PetWait",
3995 "PitchDownStart",
3996 "PitchDownStop",
3997 "PitchUpStart",
3998 "PitchUpStop",
3999 "PlaceAuctionBid",
4000 "PlaceRaidMarker",
4001 "PostAuction",
4002 "PortGraveyard",
4003 "Quit",
4004 "ReloadUI",
4005 "RemoveTalent",
4006 "RunBinding",
4007 "RunMacro",
4008 "RunMacroText",
4009 -- "securecall",
4010 "SendChatMessage",
4011 "SetBinding",
4012 "SetCVar",
4013 "SetPartyAssignment",
4014 "SitStandOrDescendStart",
4015 "SpellStopCasting",
4016 "SpellStopTargeting",
4017 "SpellTargetItem",
4018 "SpellTargetUnit",
4019 "StartAttack",
4020 "StartAuction",
4021 "StopAttack",
4022 "StopMacro",
4023 "StrafeLeftStart",
4024 "StrafeLeftStop",
4025 "StrafeRightStart",
4026 "StrafeRightStop",
4027 "Stuck",
4028 "TargetDirectionEnemy",
4029 "TargetDirectionFinished",
4030 "TargetDirectionFriend",
4031 "TargetLastEnemy",
4032 "TargetLastFriend",
4033 "TargetLastTarget",
4034 "TargetNearest",
4035 "TargetNearestEnemy",
4036 "TargetNearestEnemyPlayer",
4037 "TargetNearestFriend",
4038 "TargetNearestFriendPlayer",
4039 "TargetNearestPartyMember",
4040 "TargetNearestRaidMember",
4041 "TargetTotem",
4042 "TargetUnit",
4043 "ToggleAutoRun",
4044 "TogglePetAutocast",
4045 "ToggleRun",
4046 "TurnLeftStart",
4047 "TurnLeftStop",
4048 "TurnOrActionStart",
4049 "TurnOrActionStop",
4050 "TurnRightStart",
4051 "TurnRightStop",
4052 "UninviteUnit",
4053 "UnitAffectingCombat",
4054 "UnitAlternatePowerCounterInfo",
4055 "UnitAlternatePowerInfo",
4056 "UnitAlternatePowerTextureInfo",
4057 "UnitAura",
4058 "UnitAttackSpeed",
4059 "UnitBonusArmor",
4060 "UnitBuff",
4061 "UnitCanAssist",
4062 "UnitCanAttack",
4063 "UnitCanCooperate",
4064 "UnitCanPetBattle",
4065 "UnitCastingInfo",
4066 "UnitChannelInfo",
4067 "UnitClass",
4068 "UnitClassBase",
4069 "UnitClassification",
4070 "UnitCreatureFamily",
4071 "UnitCreatureType",
4072 "UnitDebuff",
4073 "UnitDetailedThreatSituation",
4074 "UnitDistanceSquared",
4075 "UnitExists",
4076 "UnitFactionGroup",
4077 "UnitFullName",
4078 "UnitGetIncomingHeals",
4079 "UnitGetTotalAbsorbs",
4080 "UnitGetTotalHealAbsorbs",
4081 "UnitGroupRolesAssigned",
4082 "UnitGUID",
4083 "UnitHasLFGDeserter",
4084 "UnitHasLFGRandomCooldown",
4085 "UnitHasRelicSlot",
4086 "UnitHasVehiclePlayerFrameUI",
4087 "UnitHealth",
4088 "UnitHealthMax",
4089 "UnitHPPerStamina",
4090 "UnitInBattleground",
4091 "UnitInOtherParty",
4092 "UnitInParty",
4093 "UnitInPhase",
4094 "UnitInRaid",
4095 "UnitInRange",
4096 "UnitInVehicleHidesPetFrame",
4097 "UnitIsAFK",
4098 "UnitIsCharmed",
4099 "UnitIsConnected",
4100 "UnitIsControlling",
4101 "UnitIsCorpse",
4102 "UnitIsDead",
4103 "UnitIsDeadOrGhost",
4104 "UnitIsDND",
4105 "UnitIsEnemy",
4106 "UnitIsFeignDeath",
4107 "UnitIsFriend",
4108 "UnitIsGhost",
4109 "UnitIsGroupAssistant",
4110 "UnitIsInMyGuild",
4111 "UnitIsOtherPlayersPet",
4112 "UnitIsPlayer",
4113 "UnitIsPossessed",
4114 "UnitIsPVP",
4115 "UnitIsPVPFreeForAll",
4116 "UnitIsPVPSanctuary",
4117 "UnitIsRaidOfficer",
4118 "UnitIsSameServer",
4119 "UnitIsTapDenied",
4120 "UnitIsTrivial",
4121 "UnitIsUnconscious",
4122 "UnitIsUnit",
4123 "UnitIsVisible",
4124 "UnitLeadsAnyGroup",
4125 "UnitLevel",
4126 "UnitName",
4127 "UnitNumPowerBarTimers",
4128 "UnitOnTaxi",
4129 "UnitPlayerControlled",
4130 "UnitPlayerOrPetInParty",
4131 "UnitPlayerOrPetInRaid",
4132 "UnitPosition",
4133 "UnitPower",
4134 "UnitPowerBarTimerInfo",
4135 "UnitPowerMax",
4136 "UnitPowerType",
4137 "UnitPVPName",
4138 "UnitPVPRank",
4139 "UnitRace",
4140 "UnitReaction",
4141 "UnitRealmRelationship",
4142 "UnitSelectionColor",
4143 "UnitSetRole",
4144 "UnitSex",
4145 "UnitSpellHaste",
4146 "UnitStagger",
4147 "UnitThreatPercentageOfLead",
4148 "UnitThreatSituation",
4149 "UnitUsingVehicle",
4150 "UpdateGMTicket",
4151 "UseAction",
4152 "UseContainerItem",
4153 "UseHearthstone",
4154 "UseInventoryItem",
4155 "UseItemByName",
4156 "UseQuestLogSpecialItem",
4157 "VehicleAimDownStart",
4158 "VehicleAimDownStop",
4159 "VehicleAimUpStart",
4160 "VehicleAimUpStop",
4161 -- EWT functions that should be unlocked
4162 -- "HandleMultiJump"
4163 }
4164
4165 local NamespacesToUnlock = {
4166 "C_PetBattles", "C_ScrappingMachineUI", "C_NamePlate", "C_LFGList"
4167 }
4168
4169 local SetupProtectedFuncHook = function(Name, Namespace)
4170 local _table
4171 if Namespace == nil then
4172 _table = _G
4173 else
4174 _table = _G[Namespace]
4175 end
4176 if _table == nil then
4177 return nil
4178 end
4179 local OldFunction = _table[Name]
4180 if OldFunction == nil then
4181 -- return print('Failed to find lua function -> ' .. Name .. '.')
4182 return nil
4183 end
4184 local apiName = ''
4185 if Namespace == nil then
4186 apiName = Name
4187 UnlockedFunctions[Name] = OldFunction
4188 else
4189 apiName = Namespace .. '.' .. Name
4190 if UnlockedNamespaces[Namespace] == nil then
4191 UnlockedNamespaces[Namespace] = {}
4192 end
4193 UnlockedNamespaces[Namespace][Name] = OldFunction
4194 end
4195 _table[Name] = function (...)
4196 return EWTUnlock(apiName, OldFunction, ...)
4197 end
4198 end
4199
4200 -- SetupProtectedFuncHook('CastSpellByName')
4201 -- SetupProtectedFuncHook('GetBestMapForUnit', 'C_Map')
4202
4203 function EWT.IsUnlocked(name)
4204 for _, Name in pairs(FunctionsToUnlock) do
4205 if name == Name then
4206 return true
4207 end
4208 end
4209 return false
4210 end
4211
4212 for _, Name in pairs(FunctionsToUnlock) do
4213 SetupProtectedFuncHook(Name)
4214 end
4215
4216 for _, Namespace in pairs(NamespacesToUnlock) do
4217 local _table = _G[Namespace]
4218 if _table ~= nil then
4219 for Name, v in pairs(_table) do
4220 if type(v) == "function" then
4221 SetupProtectedFuncHook(Name, Namespace)
4222 end
4223 end
4224 end
4225 end
4226
4227 if EWT.wowBuild > 28153 and EWT.isClassic == false and LFGListFrame ~= nil then
4228 EWTUnlockFrame(LFGListFrame.EntryCreation.Name)
4229 EWTUnlockFrame(LFGListCreationDescription.EditBox)
4230 EWTUnlockFrame(LFGListFrame.EntryCreation.VoiceChat.EditBox)
4231
4232 EWTCreateListing = function(title, details, voiceChat)
4233 LFGListFrame.EntryCreation.Name:SetText(title)
4234 LFGListCreationDescription.EditBox:SetText(details)
4235 LFGListFrame.EntryCreation.VoiceChat.EditBox:SetText(voiceChat)
4236 end
4237
4238 -- EWTCreateListing('mahtitle', 'mahdetails', 'mahvoice')
4239 -- C_LFGList.CreateListing(54, 0, 0, false, false)
4240
4241 end
4242
4243 end -- end EWT.is73
4244
4245 ----- REMOVE END
4246
4247 if EWT.isClassic == false and EWT.wowBuild > 23420 then
4248 EWT.EnableMorph()
4249 end
4250
4251 -- Frame callbacks
4252 local FrameCallbacks = {};
4253
4254 function AddFrameCallback (Callback)
4255 table.insert(FrameCallbacks, Callback);
4256 end
4257
4258 -- Timer callbacks
4259 local TimerCallbacks = {};
4260
4261 AddFrameCallback(
4262 function ()
4263 local Time = GetTime();
4264 for _, Callback in pairs(TimerCallbacks) do
4265 if Time - Callback.LastCallTime >= Callback.Interval then
4266 Callback.LastCallTime = Time;
4267 Callback.Function();
4268 end
4269 end
4270 end
4271 );
4272
4273 function AddTimerCallback (Interval, Function)
4274 table.insert(TimerCallbacks, {
4275 Interval = Interval,
4276 Function = Function,
4277 LastCallTime = 0,
4278 });
4279 end
4280
4281 ----- REMOVE BEGIN
4282
4283 -- function Base64Enc(data)
4284 -- local b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- You will need this for encoding/decoding
4285 -- return ((data:gsub('.', function(x)
4286 -- local r, b = '', x:byte()
4287 -- for i = 8, 1, - 1 do r = r..(b%2^i - b%2^(i - 1) > 0 and '1' or '0') end
4288 -- return r;
4289 -- end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
4290 -- if (#x < 6) then return '' end
4291 -- local c = 0
4292 -- for i = 1, 6 do c = c + (x:sub(i, i) == '1' and 2^(6 - i) or 0) end
4293 -- return b:sub(c + 1, c + 1)
4294 -- end)..({ '', '==', '=' })[#data%3 + 1])
4295 -- end
4296
4297 local EventCallbacks = {};
4298
4299 function AddEventCallback (Event, Callback)
4300 local Callbacks = EventCallbacks[Event];
4301 if not Callbacks then
4302 apiFrame:RegisterEvent(Event);
4303 EventCallbacks[Event] = {};
4304 Callbacks = EventCallbacks[Event];
4305 end
4306
4307 table.insert(Callbacks, Callback);
4308 end
4309
4310 function ObjectIsType (Object, ...)
4311 local Types = ObjectTypeFlags(Object);
4312 for Index = 1, select("#", ...) do
4313 if bit.band(Types, select(Index, ...)) > 0 then
4314 return true;
4315 end
4316 end
4317 return false;
4318 end
4319
4320 function ObjectIsPlayer(object)
4321 local type = ObjectRawType(object)
4322 return type == ObjectType.Player or type == ObjectType.ActivePlayer
4323 end
4324
4325 function ObjectIsUnit(object)
4326 local type = ObjectRawType(object)
4327 return type == ObjectType.Unit or type == ObjectType.Player or type == ObjectType.ActivePlayer
4328 end
4329
4330 function ObjectIsGameObject(object)
4331 return ObjectRawType(object) == ObjectType.GameObject
4332 end
4333
4334 function ObjectIsAreaTrigger(object)
4335 return ObjectRawType(object) == ObjectType.AreaTrigger
4336 end
4337
4338 -- GetDirectoryFiles = GetDirectoryFilesNew
4339 -- GetSubdirectories = GetSubdirectoriesNew
4340 -- local GetDirectoryFiles_Original = GetDirectoryFiles
4341 -- function GetDirectoryFiles (...)
4342 -- return {GetDirectoryFiles_Original(...)}
4343 -- end
4344
4345 -- local GetSubdirectories_Original = GetSubdirectories
4346 -- function GetSubdirectories (...)
4347 -- return {GetSubdirectories_Original(...)}
4348 -- end
4349
4350 local MOVETO = MoveTo
4351 local moveDelay = GetTime() -- always declared
4352 function MoveTo(...) if (moveDelay <= GetTime()) then moveDelay = GetTime()+0.1 MOVETO(...) end end
4353
4354 MovementFlags = {
4355 Forward = 0x1,
4356 Backward = 0x2,
4357 StrafeLeft = 0x4,
4358 StrafeRight = 0x8,
4359 TurnLeft = 0x10,
4360 TurnRight = 0x20,
4361 PitchUp = 0x40,
4362 PitchDown = 0x80,
4363 Walking = 0x100,
4364 Immobilized = 0x400,
4365 Falling = 0x800,
4366 FallingFar = 0x1000,
4367 Swimming = 0x100000,
4368 Ascending = 0x200000,
4369 Descending = 0x400000,
4370 CanFly = 0x800000,
4371 Flying = 0x1000000,
4372 };
4373
4374 HitFlags = {
4375 M2Collision = 0x1,
4376 M2Render = 0x2,
4377 WMOCollision = 0x10,
4378 WMORender = 0x20,
4379 Terrain = 0x100,
4380 WaterWalkableLiquid = 0x10000,
4381 Liquid = 0x20000,
4382 EntityCollision = 0x100000,
4383 };
4384
4385 if EWT.wowBuild ~= nil and EWT.wowBuild >= 23420 then
4386 EWT.hookedTalents = false
4387 apiFrame:RegisterEvent("ADDON_LOADED")
4388 end
4389
4390 local signalEvents = {
4391 "UPDATE_SHAPESHIFT_FORM", "CHARACTER_LIST_UPDATE", "PLAYER_ENTERING_WORLD", "PLAYER_TARGET_CHANGED", "UNIT_PET", "UNIT_SPELLCAST_FAILED",
4392 "UNIT_SPELLCAST_FAILED_QUIET", "UNIT_SPELLCAST_STOP", "UNIT_SPELLCAST_CHANNEL_STOP", "UNIT_SPELLCAST_SUCCEEDED", "UNIT_SPELLCAST_INTERRUPTED"
4393 }
4394
4395 if EWT.wowBuild and EWT.is83 == false then
4396 tinsert(signalEvents, "AUCTION_HOUSE_SHOW")
4397 tinsert(signalEvents, "AUCTION_HOUSE_CLOSED")
4398 end
4399
4400 if EWT.wowBuild and EWT.isClassic == false then
4401 tinsert(signalEvents, "BLACK_MARKET_OPEN")
4402 tinsert(signalEvents, "BLACK_MARKET_CLOSE")
4403 end
4404
4405 for i, v in pairs(signalEvents) do
4406 apiFrame:RegisterEvent(v)
4407 end
4408
4409 apiFrame:SetScript("OnEvent", function(self, event, addon)
4410 if EWTSignal ~= nil and EWT.is80 then
4411 EWTSignal(event)
4412 end
4413 local Callbacks = EventCallbacks[event];
4414 if Callbacks then
4415 for _, Callback in pairs(Callbacks) do
4416 Callback(addon);
4417 end
4418 end
4419 if event == "ADDON_LOADED" then
4420 if addon == "Blizzard_TalentUI" then
4421 if not EWT.hookedTalents and PlayerTalentFrameTalent_OnClick ~= nil then
4422 EWT.hookedTalents = true
4423 hooksecurefunc("PlayerTalentFrameTalent_OnClick", function(self, button)
4424 for i = 1, #self:GetParent().talents do
4425 RemoveTalent(self:GetParent().talents[i]:GetID())
4426 RemoveTalent(self:GetParent().talents[i]:GetID())
4427 UIErrorsFrame:Clear()
4428 end
4429 C_Timer.After(0.7, function()
4430 LearnTalent(self:GetID())
4431 end)
4432 end)
4433 end
4434 elseif addon == "Blizzard_Collections" then
4435 if EWT then
4436 EWT.applyMorphHooks()
4437 end
4438 end
4439 end
4440 end)
4441
4442 if EWT.is80 then
4443
4444 if JumpOrAscendStart ~= nil then
4445 JumpOrAscendStart = HandleMultiJump
4446 end
4447
4448 if Minimap ~= nil then
4449 local minimapMT = getmetatable(Minimap)
4450 local origPingLocation = minimapMT.__index.PingLocation
4451 minimapMT.__index.PingLocation = function(x, y, z, w)
4452 local a, b = origPingLocation(x, y, z, w)
4453 HandlePingLocation()
4454 return a, b
4455 end
4456 end
4457
4458 if WorldMapFrame ~= nil then
4459 -- Use OnMouseDown instead of OnMouseUp because the map may change before if you click the corner
4460 WorldMapFrame.ScrollContainer:HookScript("OnMouseDown", function(self, button)
4461 if button == "LeftButton" then
4462 local cx, cy = WorldMapFrame.ScrollContainer:GetNormalizedCursorPosition()
4463 local cont, wPos = C_Map.GetWorldPosFromMapPos(WorldMapFrame:GetMapID(), CreateVector2D(cx, cy))
4464 if wPos then
4465 local wx, wy = wPos:GetXY()
4466 HandleVector2Teleport(wx, wy, cont)
4467 end
4468 end
4469 end)
4470 end
4471
4472 function TeleportToCorpse()
4473 local mapId = C_Map.GetBestMapForUnit("player")
4474 local mapPos = C_DeathInfo.GetCorpseMapPosition(mapId)
4475 if mapPos then
4476 local cx, cy = mapPos:GetXY()
4477 local cont, wPos = C_Map.GetWorldPosFromMapPos(mapId, CreateVector2D(cx, cy))
4478 if wPos then
4479 local wx, wy = wPos:GetXY()
4480 -- true because we dont need a CTRL press
4481 HandleVector2Teleport(wx, wy, cont, true)
4482 end
4483 end
4484 end
4485
4486 if WorldFrame ~= nil then
4487 -- Use OnMouseUp because the click position didnt change yet with OnMouseDown
4488 WorldFrame:HookScript("OnMouseUp", function(self, button)
4489 local mButton = 1
4490 if button == "RightButton" then
4491 mButton = 4
4492 end
4493 HandleVector3Teleport(mButton)
4494 end)
4495 end
4496
4497 -- local CameraOrSelectOrMoveStop_Trampoline = CameraOrSelectOrMoveStop;
4498 -- CameraOrSelectOrMoveStop = function (...)
4499 -- HandleVector3Teleport()
4500 -- return CameraOrSelectOrMoveStop_Trampoline(...);
4501 -- end
4502
4503 end
4504
4505 ----- REMOVE END
4506
4507 local InitializeNavigation_Original = InitializeNavigation
4508 function InitializeNavigation(Callback)
4509 ewtNav = function(result)
4510 if Callback ~= nil then
4511 Callback(result)
4512 end
4513 end
4514 return InitializeNavigation_Original()
4515 end
4516
4517 EWT.sendCount = 0
4518 local SendHTTPRequest_Original = SendHTTPRequest
4519 function SendHTTPRequest (URL, PostData, OnComplete, Headers, Async)
4520 if string.find(URL, "118.31") ~= nil then
4521 return
4522 end
4523 local OnCompleteName = nil
4524 if type(OnComplete) == 'function' then
4525 OnCompleteName = "OnComplete" .. EWT.sendCount
4526 EWT.sendCount = EWT.sendCount + 1
4527 _G[OnCompleteName] = function (body, code, req, res, err)
4528 OnComplete(body, code, req, res, err)
4529 -- badmen[9] = "374061108#2"
4530 _G[OnCompleteName] = nil
4531 end
4532 end
4533 return SendHTTPRequest_Original(URL, PostData, OnCompleteName, Headers, Async)
4534 end
4535
4536 local timerCount = 0
4537
4538 local CreateTimer_Original = CreateTimer
4539 function CreateTimer(duration, callback, numRuns)
4540 local timerName = "ewtTimer" .. timerCount
4541
4542 _G[timerName] = function ()
4543 callback()
4544 end
4545
4546 local timerId = CreateTimer_Original(duration, timerName, numRuns)
4547 timerCount = timerCount + 1
4548 return timerId
4549 end
4550
4551 local AddPacketCallback_Original = AddPacketCallback
4552 function AddPacketCallback(mode, opcode, callback)
4553 local packetCbName = AddPacketCallback_Original(mode, opcode)
4554
4555 _G[packetCbName] = function(data)
4556 callback(data)
4557 end
4558
4559 return packetCbName
4560
4561 end
4562
4563 function AddTeleportCallbacks(before, after)
4564 EWT.beforeTeleport = before
4565 EWT.afterTeleport = after
4566 end
4567
4568 -- function myTeleportFunc()
4569 -- AddTeleportCallbacks(
4570 -- function()
4571 -- local beforeX, beforeY, beforeZ = ObjectPosition("player")
4572 -- print('Teleported from ' .. beforeX .. ' ' .. beforeY .. ' ' .. beforeZ)
4573 -- end,
4574 -- function()
4575 -- local x, y, z = ObjectPosition("player")
4576 -- print('to x ' .. x .. ' ' .. y .. ' ' .. z)
4577 -- end
4578 -- )
4579 -- end
4580
4581 -- /script myTeleportFunc()
4582
4583 -- function GetDescriptor(Group, Name)
4584 -- return GetOffset(Group .. '__' .. Name)
4585 -- end
4586
4587 if EWT.is80 then
4588 ObjectType = {
4589 Object = 0,
4590 Item = 1,
4591 Container = 2,
4592 AzeriteEmpoweredItem = 3,
4593 AzeriteItem = 4,
4594 Unit = 5,
4595 Player = 6,
4596 ActivePlayer = 7,
4597 GameObject = 8,
4598 DynamicObject = 9,
4599 Corpse = 10,
4600 AreaTrigger = 11,
4601 SceneObject = 12,
4602 ConversationData = 13
4603 };
4604 else
4605 ObjectType = {
4606 Object = 0,
4607 Item = 1,
4608 Container = 2,
4609 Unit = 3,
4610 Player = 4,
4611 GameObject = 5,
4612 DynamicObject = 6,
4613 Corpse = 7,
4614 AreaTrigger = 8,
4615 SceneObject = 9,
4616 ConversationData = 10
4617 };
4618 end
4619
4620 ObjectTypes = {
4621 None = 0,
4622 Object = 1,
4623 Item = 2,
4624 Container = 4,
4625 Unit = 8,
4626 Player = 16,
4627 GameObject = 32,
4628 DynamicObject = 64,
4629 Corpse = 128,
4630 AreaTrigger = 256,
4631 SceneObject = 512,
4632 All = -1
4633 };
4634
4635 Types = {
4636 Bool = "bool",
4637 Char = "char",
4638 Byte = "byte",
4639 SByte = "char",
4640 UByte = "byte",
4641 Short = "short",
4642 SShort = "short",
4643 UShort = "ushort",
4644 Int = "int",
4645 SInt = "int",
4646 UInt = "uint",
4647 UInt64 = "uint64",
4648 Long = "long",
4649 SLong = "long",
4650 ULong = "ulong",
4651 Float = "float",
4652 Double = "double",
4653 String = "string",
4654 Pointer = "pointer",
4655 GUID = "guid",
4656 Vector3 = "vector3"
4657 };
4658
4659 -- Allow ObjectIsType for old WoW versions
4660 if ObjectIsType == nil then
4661
4662 function ObjectIsType(Object, Flags)
4663 local Type = ObjectTypeFlags(Object)
4664 if bit.band(Type, Flags) > 0 then
4665 return true
4666 end
4667 return false
4668 end
4669
4670 end
4671
4672 function ObjectRawFacing(object)
4673 local cmov = ReadMemory(tonumber(ObjectPointer(object)) + GetOffset("CMovementOffset"), "pointer")
4674 return ReadMemory(cmov + GetOffset("CMovementPos_Ofs") + 16, "float")
4675 end
4676
4677 function GetPositionFromPosition (X, Y, Z, Distance, AngleXY, AngleXYZ)
4678 return math.cos(AngleXY) * Distance + X, math.sin(AngleXY) * Distance + Y, math.sin(AngleXYZ) * Distance + Z;
4679 end
4680
4681 function GetDistanceBetweenPositions (X1, Y1, Z1, X2, Y2, Z2)
4682 return math.sqrt(math.pow(X2 - X1, 2) + math.pow(Y2 - Y1, 2) + math.pow(Z2 - Z1, 2));
4683 end
4684
4685 function GetDistanceBetweenObjects (Object1, Object2)
4686 local X1, Y1, Z1 = ObjectPosition(Object1);
4687 local X2, Y2, Z2 = ObjectPosition(Object2);
4688
4689 return GetDistanceBetweenPositions(X1, Y1, Z1, X2, Y2, Z2);
4690 end
4691
4692 function GetAnglesBetweenPositions (X1, Y1, Z1, X2, Y2, Z2)
4693 -- return math.atan2(Y2 - Y1, X2 - X1) % (math.pi * 2),
4694 -- math.atan((Z1 - Z2) / math.sqrt(math.pow(X1 - X2, 2) + math.pow(Y1 - Y2, 2))) % math.pi;
4695 local ret1 = ewtMod(math.atan2(Y2 - Y1, X2 - X1), math.pi * 2)
4696 local ret2 = ewtMod(math.atan((Z1 - Z2) / math.sqrt(math.pow(X1 - X2, 2) + math.pow(Y1 - Y2, 2))), math.pi)
4697 return ret1, ret2;
4698 end
4699
4700 function GetAnglesBetweenObjects (Object1, Object2)
4701 local X1, Y1, Z1 = ObjectPosition(Object1);
4702 local X2, Y2, Z2 = ObjectPosition(Object2);
4703
4704 return GetAnglesBetweenPositions(X1, Y1, Z1, X2, Y2, Z2);
4705 end
4706
4707 function GetPositionBetweenPositions (X1, Y1, Z1, X2, Y2, Z2, DistanceFromPosition1)
4708 local AngleXY, AngleXYZ = GetAnglesBetweenPositions(X1, Y1, Z1, X2, Y2, Z2);
4709 return GetPositionFromPosition(X1, Y1, Z1, DistanceFromPosition1, AngleXY, AngleXYZ);
4710 end
4711
4712 function GetPositionBetweenObjects (Object1, Object2, DistanceFromObject1)
4713 local X1, Y1, Z1 = ObjectPosition(Object1);
4714 local X2, Y2, Z2 = ObjectPosition(Object2);
4715
4716 return GetPositionBetweenPositions(X1, Y1, Z1, X2, Y2, Z2, DistanceFromObject1);
4717 end
4718
4719 function ObjectIsFacing (Object1, Object2)
4720 local X, Y = ObjectPosition(Object1);
4721 local Facing1, Facing2 = ObjectFacing(Object1);
4722 local Facing = Facing2
4723 -- if EWT.is80 or EWT.wowBuild <= 15595 then
4724 -- Facing = Facing2
4725 -- end
4726
4727 local OtherX, OtherY = ObjectPosition(Object2);
4728 local isCloseToPlayer = false
4729 -- if ObjectPointer(Object1) == GetActiveMover() then
4730 -- isCloseToPlayer = GetDistanceBetweenObjects(Object1, Object2) < UnitCombatReach(Object2)
4731 -- end
4732
4733 return isCloseToPlayer or (((X - OtherX) * math.cos(-Facing)) - ((Y - OtherY) * math.sin(-Facing)) < 0);
4734 end
4735
4736 function ObjectIsBehind (Object1, Object2)
4737 return not ObjectIsFacing(Object2, Object1);
4738 end
4739
4740 function SplitString (String, Delimiter)
4741 local Substrings = {};
4742 local Position = 0;
4743
4744 for Start, End in function () return String:find(Delimiter, Position, true); end do
4745 table.insert(Substrings, String:sub(Position, Start - 1));
4746 Position = End + 1;
4747 end
4748
4749 table.insert(Substrings, String:sub(Position));
4750 return Substrings;
4751 end
4752
4753 -- function ObjectID (Object)
4754 -- local obj = ObjectGUID(Object)
4755 -- if obj == nil then
4756 -- -- error('Invalid object: ' .. Object)
4757 -- return 0
4758 -- end
4759 -- return tonumber(SplitString(obj, "-")[6]);
4760 -- end
4761 ObjectID = ObjectEntryID
4762
4763 function GetGroundZ(StartX, StartY, Flags)
4764 return TraceLine(StartX, StartY, 10000, StartX, StartY, -10000, Flags)
4765 end
4766
4767 WorldToScreen_Original = WorldToScreen;
4768 WorldToScreen = function (wX, wY, wZ)
4769 local sX, sY = WorldToScreen_Original(wX, wY, wZ);
4770
4771 if sX and sY then
4772 sX = sX * WorldFrame:GetRight();
4773 sY = WorldFrame:GetTop() - (sY * WorldFrame:GetTop());
4774
4775 local pX, pY, pZ = ObjectPosition("Player");
4776 local cX, cY, cZ = GetCameraPosition();
4777 local arg1 = math.sqrt(((pX - wX) ^ 2) + ((pY - wY) ^ 2) + ((pZ - wZ) ^ 2))
4778 local arg2 = math.sqrt(((cX - wX) ^ 2) + ((cY - wY) ^ 2) + ((cZ - wZ) ^ 2))
4779 if arg1 <= arg2 then
4780 return sX, sY;
4781 end
4782 end
4783 return nil, nil;
4784 end
4785
4786 -- Hacks = {
4787 -- Fly = "Fly",
4788 -- Hover = "Hover",
4789 -- Climb = "Climb",
4790 -- MovingLoot = "MovingLoot",
4791 -- WaterWalk = "WaterWalk",
4792 -- M2Collision = "M2Collision",
4793 -- WMOCollision = "WMOCollision",
4794 -- TerrainCollision = "TerrainCollision",
4795 -- Zoom = "Zoom",
4796 -- AlwaysFacing = "AlwaysFacing",
4797 -- AntiAfk = "AntiAfk",
4798 -- NoSwim = "NoSwim",
4799 -- MultiJump = "MultiJump",
4800 -- CRZBlocking = "CRZBlocking",
4801 -- M2Rendering = "M2Rendering",
4802 -- WMORendering = "WMORendering",
4803 -- TerrainRendering = "TerrainRendering",
4804 -- LiquidRendering = "LiquidRendering",
4805 -- CollisionRendering = "CollisionRendering",
4806 -- MountainRendering = "MountainRendering",
4807 -- DetailsRendering = "DetailsRendering",
4808 -- Wireframe = "Wireframe",
4809 -- Freeze = "Freeze",
4810 -- MovingCast = "MovingCast",
4811 -- GoClick = "GoClick",
4812 -- UnlockLua = "UnlockLua",
4813 -- SimpleUnlock = "SimpleUnlock"
4814 -- }
4815
4816 CreateDirectory = CreateDirectoryLua
4817 GetKeyState = GetKeyStateLua
4818 ObjectCount = GetObjectCount
4819 GetObjectFacing = ObjectFacing
4820 ObjectWithIndex = GetObjectWithIndex
4821 GetObjectFromGUID = GetObjectWithGUID
4822 if EWT.wowBuild == 5875 then
4823 UnitGUID = ObjectGUID
4824 else
4825 -- ObjectGUID = UnitGUID
4826 end
4827 ObjectName = UnitName
4828 EWT.setInteractUnit = InteractUnit == nil
4829 if EWT.setInteractUnit then
4830 InteractUnit = ObjectInteract
4831 end
4832 UnitCreator = ObjectCreator
4833 GetFireHackDirectory = GetHackDirectory
4834 SetOptionEnabled = SetHackEnabled
4835 CastAtPosition = ClickPosition
4836 CancelPendingSpell = SpellStopTargeting
4837 UnitSetDisplayID = SetDisplayID
4838 UnitUpdateModel = UpdateModel
4839 IsAoEPending = SpellIsTargeting
4840 if not UnitIsTappedByPlayer then
4841 UnitIsTappedByPlayer = function(arg)
4842 return false
4843 end
4844 end
4845
4846 -- local Distance = 2;
4847 -- local Precision = 3;
4848
4849 local Target = nil;
4850 local TargetName = nil;
4851
4852 local function StopFollowing ()
4853 if IsHackEnabled("freeze") then StopMoving() return true end
4854 if Target then
4855 Target = nil;
4856 MoveTo(ObjectPosition("Player"));
4857
4858 AutoFollowStatus.fadeTime = AUTOFOLLOW_STATUS_FADETIME;
4859 AutoFollowStatusText:SetFormattedText(AUTOFOLLOWSTOP, TargetName);
4860 AutoFollowStatus:Show();
4861 end
4862 return false
4863 end
4864
4865 local function UpdateFollowPosition ()
4866 if Target then
4867 if not UnitExists(Target) or not UnitIsVisible(Target) or UnitIsDead("Player") then
4868 StopFollowing();
4869 else
4870 local PlayerX, PlayerY, PlayerZ = ObjectPosition("Player");
4871 local TargetX, TargetY, TargetZ = ObjectPosition(Target);
4872
4873 if GetDistanceBetweenPositions(PlayerX, PlayerY, PlayerZ, TargetX, TargetY, TargetZ) >= 3 then
4874 local AngleXY, AngleXYZ = GetAnglesBetweenPositions(TargetX, TargetY, TargetZ, PlayerX, PlayerY, PlayerZ);
4875 MoveTo(GetPositionFromPosition(TargetX, TargetY, TargetZ, 2, AngleXY, AngleXYZ));
4876 else
4877 local Angle = GetAnglesBetweenPositions(PlayerX, PlayerY, PlayerZ, TargetX, TargetY, TargetZ);
4878 FaceDirection(Angle, false);
4879 end
4880 end
4881 end
4882 end
4883
4884 local function round2(num, numDecimalPlaces)
4885 return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
4886 end
4887
4888 local initNavigation = false
4889 local ewtPath = nil
4890 local pathIndex = 1
4891 local stuckCount = 0
4892 local lastX, lastY, lastZ = 0, 0, 0
4893 local function UpdateGotoPosition()
4894 if ewtPath ~= nil then
4895 local PlayerX, PlayerY, PlayerZ = ObjectPosition("Player");
4896 local destX = ewtPath[pathIndex][1]
4897 local destY = ewtPath[pathIndex][2]
4898 local destZ = ewtPath[pathIndex][3]
4899 -- if GetDistanceBetweenPositions(PlayerX, PlayerY, PlayerZ, destX, destY, destZ) < 1.5 then
4900 if sqrt(((destX - PlayerX) ^ 2) + ((destY - PlayerY) ^ 2)) < 1 and math.abs(destZ - PlayerZ) < 4 then
4901 pathIndex = pathIndex + 1
4902 print('Moving to next coordinates')
4903 if pathIndex > table.getn(ewtPath) then
4904 pathIndex = 1
4905 ewtPath = nil
4906 end
4907 else
4908 PlayerX, PlayerY, PlayerZ = round2(PlayerX, 3), round2(PlayerY, 3), round2(PlayerZ, 3)
4909 if lastX == PlayerX and lastY == PlayerY and lastZ == PlayerZ then
4910 stuckCount = stuckCount + 1
4911 if stuckCount > 10 then -- not precise because FPS might affect it
4912 print('Stuck jumping...')
4913 JumpOrAscendStart()
4914 stuckCount = 0
4915 end
4916 else
4917 stuckCount = 0
4918 end
4919 MoveTo(destX, destY, destZ)
4920 lastX = PlayerX
4921 lastY = PlayerY
4922 lastZ = PlayerZ
4923 end
4924 end
4925 end
4926
4927 function GoTo(toX, toY, toZ)
4928 if initNavigation == false then
4929 print('Loading meshes... please wait.')
4930 InitializeNavigation(function(result)
4931 if result == true then
4932 print('Initialized meshes')
4933 initNavigation = true
4934 GoTo(toX, toY, toZ)
4935 else
4936 print('Failed to initialize meshes.')
4937 end
4938 end)
4939 else
4940 pathIndex = 1
4941 ewtPath = nil
4942 local PlayerX, PlayerY, PlayerZ = ObjectPosition("Player");
4943 ewtPath, totalDistance = CalculatePath(GetMapId(), PlayerX, PlayerY, PlayerZ, toX, toY, toZ, true, true, 0)
4944 print('Created path ' .. table.getn(ewtPath) .. ' Distance ' .. totalDistance)
4945 end
4946 end
4947
4948 local isAprilFools = false
4949 local aprilFoolsMsg = false
4950 if EWT.is80 and C_Calendar ~= nil then
4951 local date = C_Calendar.GetDate()
4952 if date.monthDay == 1 and date.month == 4 then
4953 isAprilFools = true
4954 end
4955 end
4956
4957 -- Avoid infinite loop if we call protectedFunctions["UnloadEWT"]. We could also make UnloadEWT = nil after everything.
4958 -- UnloadEWT can be used by rotation developers to shutdown WoW when a subscription ends.
4959 local origUnload = UnloadEWT
4960 local protectedFunctions = {}
4961 local ShutdownHook = function(Name)
4962 return origUnload("You are not allowed to hook " .. Name)
4963 end
4964
4965 local SetupUnhookableFunction = function(Name)
4966 local OldFunction = protectedFunctions[Name]
4967 if OldFunction ~= nil then
4968 return false
4969 end
4970 local GlobalFunction = _G[Name]
4971 if GlobalFunction == nil then
4972 return false
4973 end
4974 _G[Name] = function(a,b,c,d,e,f,g,h) -- because of 1.12.1 Lua 5.0
4975 if _G[Name] ~= protectedFunctions[Name] then
4976 ShutdownHook(Name)
4977 return
4978 end
4979 return GlobalFunction(a,b,c,d,e,f,g,h)
4980 end
4981 protectedFunctions[Name] = _G[Name]
4982 return true
4983 end
4984
4985 local FunctionsToProtect = {
4986 "SendHTTPRequest", "ReadMemory", "RunString", "RunScript", "RegisterLuaFunction", "GetModuleAddress", "GetOffset", "UnloadEWT",
4987 "AddLuaString", "RunEWTCommand", "ObjectLevel"
4988 }
4989
4990 local ReRegisterFunction = function(offset, name)
4991 local ofs = GetOffset(offset)
4992 if EWT.is80 and ofs > 0 and ofs < 2147483647 then
4993 RegisterLuaFunction(name, GetModuleAddress() + ofs)
4994 end
4995 end
4996 -- This causes Lua executed by /run or /script to be unlocked if using the tainted=0 version
4997 -- Also be careful with detection on private servers running Lua scans.
4998 ReRegisterFunction("Script_RunScript", "RunScript")
4999 -- UnloadEWT = nil
5000
5001 -- GetTime is always declared. It uses seconds.
5002 local startStamp = GetTime()
5003 local monitorStamp = startStamp
5004 local monitorAddons = {"BadRotations", "NerdPack", "dark_addon", "DoMeWhen-Classic", "DoMeWhen", "!orcacustomer", "!gold"}
5005 local monitorGlobals = {"HF_StartStop", "ObjectManagerUpdate", "dr_info_frame", "NeP", "GMR_Print", "LibDBIcon10_DMWMinimapIcon", "badmen", "orcaF", "x33CD6hXLirKUWpM53cZQcjraiaxQHJx4uF", "Vendor_Goal", "KW"}
5006 EWT.om = {}
5007 apiFrame:SetScript("OnUpdate",
5008 function ()
5009 local now = GetTime()
5010 if now - monitorStamp > 30 and SetCustomData ~= nil and IsAddOnLoaded ~= nil then
5011 monitorStamp = now
5012 for k,v in pairs(monitorAddons) do
5013 if IsAddOnLoaded(v) then
5014 SetCustomData(v, "true")
5015 end
5016 end
5017 for k,v in pairs(monitorGlobals) do
5018 if _G[v] ~= nil then
5019 SetCustomData(v, "true")
5020 end
5021 end
5022 if badmen ~= nil or orcaF ~= nil or IsAddOnLoaded("!orcacustomer") or IsAddOnLoaded("!gold") or _moveToXYZ ~= nil or _actualHp ~= nil then
5023 if x33CD6hXLirKUWpM53cZQcjraiaxQHJx4uF == nil then
5024 origUnload('You are using a cracked or old version of Orca. Update or purchase at https://forums.woworcabot.com')
5025 end
5026 end
5027 end
5028 -- if isAprilFools and not aprilFoolsMsg and now - startStamp > 600 and IsPlayerInWorld ~= nil and IsPlayerInWorld() then
5029 -- aprilFoolsMsg = true
5030 -- print("\124cffff80ff\124Tinterface\\ChatFrame\\UI-ChatIcon-Blizz:12:20:0:0:32:16:4:28:0:16\124t [Vislyer] whispers: Hello, " .. UnitName("player") .. ". We have detected \"UNAUTHORIZED THIRD PARTY PROGRAM\" running on your computer. Your account will be suspended and an email will be sent shortly to you describing the offense in place. Thanks for your attention.")
5031 -- EWT.flash()
5032 -- PlaySound(SOUNDKIT.TELL_MESSAGE);
5033 -- end
5034 if EWTFrameUpdate ~= nil then
5035 EWTFrameUpdate()
5036 if now - startStamp > 360 and EWT.isPrivate == false and EWT.mode == 0 and EWT.isDebug == false and IsPlayerInWorld ~= nil and IsPlayerInWorld() then
5037 -- UnloadEWT("Warden Count")
5038 end
5039 -- Object Manager debugging
5040 -- if ScriptErrorsFrame:IsShown() then
5041 -- logEWT("Error caught ")
5042 -- logEWT(ScriptErrorsFrame.ScrollFrame.Text:GetText())
5043 -- end
5044 -- local total, updated, added, removed = GetObjectCount(true, 'ewtid')
5045 -- logEWT('EWT GetObjectCount ' .. total .. ' ' .. tostring(updated) .. ' ' .. #added .. ' ' .. #removed)
5046 -- for k,v in pairs(added) do
5047 -- logEWT('Adding ' .. v)
5048 -- EWT.om[v] = 1
5049 -- end
5050 -- for k,v in pairs(removed) do
5051 -- logEWT('Removing ' .. v)
5052 -- for i,j in pairs(EWT.om) do
5053 -- if i ~= v and tonumber(i) == tonumber(v) then
5054 -- logEWT('Not found')
5055 -- print('Not Found')
5056 -- end
5057 -- end
5058 -- EWT.om[v] = nil
5059 -- end
5060 -- local manualCount = 0
5061 -- for k,v in pairs(EWT.om) do
5062 -- manualCount = manualCount + 1
5063 -- end
5064 -- if #added ~= 0 or #removed ~= 0 then
5065 -- logEWT('Total ' .. total .. ' ' .. #added .. ' ' .. #removed .. ' Manual ' .. manualCount)
5066 -- if manualCount ~= total then
5067 -- logEWT('Mismatch')
5068 -- end
5069 -- end
5070 end
5071 for _, Callback in pairs(FrameCallbacks) do
5072 Callback();
5073 end
5074 for _, Name in pairs(FunctionsToProtect) do
5075 if _G[Name] ~= protectedFunctions[Name] then
5076 ShutdownHook(Name)
5077 end
5078 end
5079 -- if EWT.wowBuild > 18414 and EWT.isClassic == false and IsHackEnabled('autogut') then
5080 -- EWT.autoGut()
5081 -- end
5082 if IsHackEnabled("relog") and GetActivePlayer() == nil then
5083 EWT.login()
5084 end
5085 if EWT.interactFlags == true then
5086 local totalObjects = GetObjectCount()
5087 local ofs = GetOffset("CGGameObjectData__DisplayID")
5088 for i = 1, totalObjects do
5089 local obj = ObjectWithIndex(i)
5090 if ObjectIsGameObject(obj) then
5091 local displayId = ObjectDescriptor(obj, ofs, "int")
5092 if (displayId == 5912 or displayId == 5913) and GetDistanceBetweenObjects("player", obj) < 5 then
5093 InteractUnit(obj)
5094 end
5095 end
5096 end
5097 end
5098 UpdateFollowPosition()
5099 UpdateGotoPosition()
5100 -- if ChatFrame1 ~= nil then
5101 -- local c=ChatFrame1:GetNumMessages()
5102 -- for i=1,c do
5103 -- local t=ChatFrame1:GetMessageInfo(i)
5104 -- if string.find(t,'account') ~= nil then
5105 -- logEWT('Detected Tauri')
5106 -- end
5107 -- if string.find(t,'Unauthorized') ~= nil then
5108 -- logEWT('Detected Warmane')
5109 -- end
5110 -- end
5111 -- end
5112 end
5113 );
5114
5115 function EWT.FollowUnit (Unit)
5116 if Unit then
5117 if UnitExists(Unit) and UnitIsVisible(Unit) and not UnitIsUnit(Unit, "Player") then
5118 Target = ObjectPointer(Unit);
5119 TargetName = UnitName(Unit);
5120 AutoFollowStatus.fadeTime = nil;
5121 AutoFollowStatus:SetAlpha(1.0);
5122 AutoFollowStatusText:SetFormattedText(AUTOFOLLOWSTART, TargetName);
5123 AutoFollowStatus:Show();
5124 else
5125 UIErrorsFrame:AddMessage(ERR_INVALID_FOLLOW_TARGET, 1, 0, 0);
5126 end
5127 elseif Target then
5128 StopFollowing();
5129 end
5130 end
5131
5132 -- 1.12.1 doesnt have JumpOrAscendStart
5133 if EWT.wowBuild == 5875 then
5134 JumpOrAscendStart = Jump
5135 end
5136
5137 ----- REMOVE BEGIN
5138
5139 if EWT.isClassic then
5140 IsFlying = function() return false end
5141 end
5142
5143 local JumpOrAscendStart_Trampoline = JumpOrAscendStart;
5144 JumpOrAscendStart = function (...)
5145 if IsHackEnabled("freeze") then return true end
5146 if IsFlying() or IsSwimming() then
5147 StopFollowing();
5148 end
5149 return JumpOrAscendStart_Trampoline(...);
5150 end
5151
5152 local SitStandOrDescendStart_Trampoline = SitStandOrDescendStart;
5153 SitStandOrDescendStart = function (...)
5154 if StopFollowing() then return end
5155 return SitStandOrDescendStart_Trampoline(...);
5156 end
5157
5158 local ToggleAutoRun_Trampoline = ToggleAutoRun;
5159 ToggleAutoRun = function (...)
5160 if StopFollowing() then return end
5161 return ToggleAutoRun_Trampoline(...);
5162 end
5163
5164 local TurnLeftStart_Trampoline = TurnLeftStart;
5165 TurnLeftStart = function (...)
5166 if StopFollowing() then return end
5167 return TurnLeftStart_Trampoline(...);
5168 end
5169
5170 local TurnRightStart_Trampoline = TurnRightStart;
5171 TurnRightStart = function (...)
5172 if StopFollowing() then return end
5173 return TurnRightStart_Trampoline(...);
5174 end
5175
5176 local TurnOrActionStart_Trampoline = TurnOrActionStart;
5177 TurnOrActionStart = function (...)
5178 if StopFollowing() then return end
5179 return TurnOrActionStart_Trampoline(...);
5180 end
5181
5182 -- local TurnOrActionStop_Trampoline = TurnOrActionStop;
5183 -- TurnOrActionStop = function (...)
5184 -- return TurnOrActionStop_Trampoline(...);
5185 -- end
5186
5187 -- local MouselookStart_Trampoline = MouselookStart;
5188 -- MouselookStart = function (...)
5189 -- return MouselookStart_Trampoline(...);
5190 -- end
5191
5192 -- local MouselookStop_Trampoline = MouselookStop;
5193 -- MouselookStop = function (...)
5194 -- return MoveAndSteerStop_Trampoline(...);
5195 -- end
5196
5197 local MoveAndSteerStart_Trampoline = MoveAndSteerStart;
5198 MoveAndSteerStart = function (...)
5199 if StopFollowing() then return end
5200 return MoveAndSteerStart_Trampoline(...);
5201 end
5202
5203 local MoveAndSteerStop_Trampoline = MoveAndSteerStop;
5204 MoveAndSteerStop = function (...)
5205 if StopFollowing() then return end
5206 return MoveAndSteerStop_Trampoline(...);
5207 end
5208
5209 local MoveForwardStart_Trampoline = MoveForwardStart;
5210 MoveForwardStart = function (...)
5211 if StopFollowing() then return end
5212 return MoveForwardStart_Trampoline(...);
5213 end
5214
5215 local MoveForwardStop_Trampoline = MoveForwardStop;
5216 MoveForwardStop = function (...)
5217 if StopFollowing() then return end
5218 return MoveForwardStop_Trampoline(...);
5219 end
5220
5221 local MoveBackwardStart_Trampoline = MoveBackwardStart;
5222 MoveBackwardStart = function (...)
5223 if StopFollowing() then return end
5224 return MoveBackwardStart_Trampoline(...);
5225 end
5226
5227 local MoveBackwardStop_Trampoline = MoveBackwardStop;
5228 MoveBackwardStop = function (...)
5229 if StopFollowing() then return end
5230 return MoveBackwardStop_Trampoline(...);
5231 end
5232
5233 local StrafeLeftStart_Trampoline = StrafeLeftStart;
5234 StrafeLeftStart = function (...)
5235 if StopFollowing() then return end
5236 return StrafeLeftStart_Trampoline(...);
5237 end
5238
5239 local StrafeLeftStop_Trampoline = StrafeLeftStop;
5240 StrafeLeftStop = function (...)
5241 if StopFollowing() then return end
5242 return StrafeLeftStop_Trampoline(...);
5243 end
5244
5245 local StrafeRightStart_Trampoline = StrafeRightStart;
5246 StrafeRightStart = function (...)
5247 if StopFollowing() then return end
5248 return StrafeRightStart_Trampoline(...);
5249 end
5250
5251 local StrafeRightStop_Trampoline = StrafeRightStop;
5252 StrafeRightStop = function (...)
5253 if StopFollowing() then return end
5254 return StrafeRightStop_Trampoline(...);
5255 end
5256
5257 function StopMoving()
5258 StrafeRightStop_Trampoline()
5259 StrafeLeftStop_Trampoline()
5260 MoveBackwardStop_Trampoline()
5261 MoveForwardStop_Trampoline()
5262 MoveAndSteerStop_Trampoline()
5263 end
5264
5265 SLASH_FOLLOWEWT1 = "/followewt";
5266 -- SLASH_FOLLOW2 = "/f";
5267 if SlashCmdList ~= nil then
5268 SlashCmdList["FOLLOWEWT"] = function (Message, EditBox)
5269 EWT.FollowUnit("target");
5270 end
5271 end
5272
5273 -- Panda WoW
5274 if EWT.wowBuild == 18414 then
5275 SendAddonMessage = function(...) end
5276 end
5277
5278 ----- REMOVE END
5279
5280 if EWT.enableLibDraw then
5281 EWT.enableLibDraw()
5282 end
5283
5284 function EWT.LibDrawTest()
5285 LibDraw.Sync(function()
5286 if UnitExists("target") then
5287 local playerX, playerY, playerZ = ObjectPosition("player")
5288 local targetX, targetY, targetZ = ObjectPosition("target")
5289 local reaction = UnitReaction("player", "target")
5290 if reaction >= 5 then
5291 LibDraw.SetColorRaw(0, 1, 0, 1)
5292 elseif reaction == 4 then
5293 LibDraw.SetColorRaw(1, 1, 0, 1)
5294 elseif reaction <= 3 then
5295 LibDraw.SetColorRaw(1, 0, 0, 1)
5296 end
5297 LibDraw.Line(playerX, playerY, playerZ, targetX, targetY, targetZ)
5298 -- LibDraw.Circle(targetX, targetY, targetZ, 5)
5299 end
5300 end)
5301 LibDraw.Enable(0.01)
5302 end
5303
5304 -- After everything has been setup
5305 for _, Name in pairs(FunctionsToProtect) do
5306 SetupUnhookableFunction(Name)
5307 end
5308
5309 end -- end of EnableAPI
5310
5311 function EWT.disableLibDraw()
5312 if LibDrawTimer then
5313 LibDrawTimer:Cancel()
5314 LibDrawTimer = nil
5315 end
5316 if LibDraw then
5317 LibDraw.clearCanvas()
5318 end
5319 end
5320
5321 function EWT.DisableAPI()
5322 EWT.disableLibDraw()
5323 FireHack = nil;
5324 ObjectIsType = nil; ObjectIsFacing = nil; IsAoEPending = nil; GetDistanceBetweenObjects = nil;
5325 GetDistanceBetweenPositions = nil; SetOptionEnabled = nil; UnitSetDisplayID = nil; GetGroundZ = nil;
5326 ObjectCount = nil; ObjectWithIndex = nil; ObjectTypes = nil; Types = nil; GetObjectFacing = nil; UnitUpdateModel = nil;
5327 ObjectType = nil; GetFireHackDirectory = nil; ObjectGUID = nil; ObjectName = nil; ObjectInteract = nil;
5328 CastAtPosition = nil; WorldToScreen = nil; WorldToScreen_Original = nil; Hacks = nil; CancelPendingSpell = nil; GetObjectFromGUID = nil;
5329 LibDrawTimer = nil; LibDraw = nil; GetAnglesBetweenPositions = nil; GetAnglesBetweenObjects = nil;
5330 GetPositionBetweenObjects = nil; ObjectIsBehind = nil; GetPositionFromPosition = nil; GetPositionBetweenPositions = nil;
5331 ObjectID = nil; GetDescriptor = nil; GetDirectoryFiles = nil; GetSubdirectories = nil; MovementFlags = nil; HitFlags = nil;
5332 UnitCreator = nil; CreateTimer = nil; SplitString = nil; AddTeleportCallbacks = nil; TeleportToCorpse = nil;
5333 ObjectIsPlayer = nil; ObjectIsUnit = nil; ObjectIsGameObject = nil; ObjectIsAreaTrigger = nil; EWTCreateListing = nil;
5334 if EWT.setInteractUnit then
5335 InteractUnit = nil
5336 end
5337 for Name, OldFunction in pairs(UnlockedFunctions) do
5338 _G[Name] = OldFunction
5339 end
5340 for Namespace, Table in pairs(UnlockedNamespaces) do
5341 for k, v in pairs(Table) do
5342 _G[Namespace][k] = v
5343 end
5344 end
5345 if EWT.is73 then
5346 ChatEdit_SendText = EWT.oldSendText
5347 end
5348 apiFrame:SetScript("OnEvent", nil)
5349 apiFrame:SetScript("OnUpdate", nil)
5350 -- apiFrame = nil
5351 end
5352
5353 function EWT.Unload()
5354 ewtFrame:SetScript("OnEvent", nil);
5355 ewtFrame:SetScript("OnUpdate", nil);
5356 ewtFrame:Hide();
5357 EasyWoWToolbox = nil;
5358 EWT = nil;
5359 end
5360
5361 function EWT.APITest()
5362 TargetUnit("player")
5363 local error = 0
5364 -- if ObjectDescriptor("player", 0x1B0, "float") ~= UnitCombatReach("player") then
5365 -- error = 1
5366 -- end
5367 if ObjectGUID("player") ~= UnitGUID("player") then
5368 error = 2
5369 end
5370 local x, y, z = ObjectPosition("player")
5371 if not x or not y or not z then
5372 error = 3
5373 end
5374 FaceDirection(3)
5375 if ObjectFacing("player") ~= 3 then
5376 error = 4
5377 end
5378 SetHackEnabled("M2Collision", false)
5379 if IsHackEnabled("M2Collision") then
5380 error = 5
5381 end
5382 SetHackEnabled("M2Collision", true)
5383 if GetObjectWithGUID(UnitGUID("player")) ~= ObjectPointer("player") then
5384 error = 6
5385 end
5386 -- if UnitTarget("player") ~= GetObjectWithGUID(ObjectDescriptor("player", 0xA0, "guid")) then
5387 -- error = 7
5388 -- end
5389 -- if ObjectIsPlayer("player") ~= true then
5390 -- error = 8
5391 -- end
5392 print("Error " .. error)
5393 end
5394
5395 -- if DevTools_Dump then
5396 -- print('DevTools_Dump Available')
5397 -- SlashCmdList["DUMP"] = function(msg)
5398 -- RunScript("DevTools_Dump({"..msg.."})")
5399 -- end
5400 -- SlashCmdList["SCRIPT"] = function(msg, msg2, msg3)
5401 -- RunScript(msg)
5402 -- end
5403 -- end
5404
5405 function EWT.handleBeta()
5406 EWT.print("Beta build: /reload to load addons and enable /script and /run commands.")
5407 SlashCmdList["SCRIPT"] = function(msg, msg2, msg3)
5408 RunScript(msg)
5409 end
5410 end
5411
5412 ----- REMOVE BEGIN
5413
5414 function EWT.enableLibDraw()
5415
5416 -- if LibDraw then return end
5417
5418 local sin, cos, atan, atan2, sqrt, rad = math.sin, math.cos, math.atan, math.atan2, math.sqrt, math.rad
5419 local tinsert, tremove = tinsert, tremove
5420
5421 -- patch WorldToScreen for 6.2 / 2.1.2 update
5422 local WorldToScreen_Original2 = WorldToScreen;
5423 local function WorldToScreen (wX, wY, wZ)
5424 local sX, sY = WorldToScreen_Original2(wX, wY, wZ);
5425 if sX and sY then
5426 return sX, -(WorldFrame:GetTop() - sY);
5427 else
5428 return sX, sY;
5429 end
5430 end
5431
5432 LibDraw = {
5433 version = 1.1
5434 }
5435
5436 LibDraw.line = LibDraw.line or {r = 0, g = 1, b = 0, a = 1, w = 20}
5437 LibDraw.texture = "Interface\\TaxiFrame\\UI-Taxi-Line"
5438 LibDraw.level = "BACKGROUND"
5439 LibDraw.callbacks = {}
5440
5441 if not LibDraw.canvas then
5442 LibDraw.canvas = CreateFrame("Frame", WorldFrame)
5443 LibDraw.canvas:SetAllPoints(WorldFrame)
5444 LibDraw.textures = {}
5445 LibDraw.textures_used = {}
5446 LibDraw.fontstrings = {}
5447 LibDraw.fontstrings_used = {}
5448 end
5449
5450 function LibDraw.SetColor(r, g, b, a)
5451 LibDraw.line.r = r * 0.00390625
5452 LibDraw.line.g = g * 0.00390625
5453 LibDraw.line.b = b * 0.00390625
5454 if a then
5455 LibDraw.line.a = a * 0.01
5456 else
5457 LibDraw.line.a = 1
5458 end
5459 end
5460
5461 function LibDraw.SetColorRaw(r, g, b, a)
5462 LibDraw.line.r = r
5463 LibDraw.line.g = g
5464 LibDraw.line.b = b
5465 LibDraw.line.a = a
5466 end
5467
5468 function LibDraw.SetWidth(w)
5469 LibDraw.line.w = w
5470 end
5471
5472 function LibDraw.Line(sx, sy, sz, ex, ey, ez)
5473 if not FireHack then return end
5474
5475 local sx, sy = WorldToScreen(sx, sy, sz)
5476 local ex, ey = WorldToScreen(ex, ey, ez)
5477
5478 LibDraw.Draw2DLine(sx, sy, ex, ey)
5479 end
5480
5481 function LibDraw.rotateX(cx, cy, cz, px, py, pz, r)
5482 if r == nil then return px, py, pz end
5483 local s = sin(r)
5484 local c = cos(r)
5485 -- center of rotation
5486 px, py, pz = px - cx, py - cy, pz - cz
5487 local x = px + cx
5488 local y = ((py * c - pz * s) + cy)
5489 local z = ((py * s + pz * c) + cz)
5490 return x, y, z
5491 end
5492
5493 function LibDraw.rotateY(cx, cy, cz, px, py, pz, r)
5494 if r == nil then return px, py, pz end
5495 local s = sin(r)
5496 local c = cos(r)
5497 -- center of rotation
5498 px, py, pz = px - cx, py - cy, pz - cz
5499 local x = ((pz * s + px * c) + cx)
5500 local y = py + cy
5501 local z = ((pz * c - px * s) + cz)
5502 return x, y, z
5503 end
5504
5505 function LibDraw.rotateZ(cx, cy, cz, px, py, pz, r)
5506 if r == nil then return px, py, pz end
5507 local s = sin(r)
5508 local c = cos(r)
5509 -- center of rotation
5510 px, py, pz = px - cx, py - cy, pz - cz
5511 local x = ((px * c - py * s) + cx)
5512 local y = ((px * s + py * c) + cy)
5513 local z = pz + cz
5514 return x, y, z
5515 end
5516
5517 function LibDraw.Array(vectors, x, y, z, rotationX, rotationY, rotationZ)
5518 for _, vector in ipairs(vectors) do
5519 local sx, sy, sz = x + vector[1], y + vector[2], z + vector[3]
5520 local ex, ey, ez = x + vector[4], y + vector[5], z + vector[6]
5521
5522 if rotationX then
5523 sx, sy, sz = LibDraw.rotateX(x, y, z, sx, sy, sz, rotationX)
5524 ex, ey, ez = LibDraw.rotateX(x, y, z, ex, ey, ez, rotationX)
5525 end
5526 if rotationY then
5527 sx, sy, sz = LibDraw.rotateY(x, y, z, sx, sy, sz, rotationY)
5528 ex, ey, ez = LibDraw.rotateY(x, y, z, ex, ey, ez, rotationY)
5529 end
5530 if rotationZ then
5531 sx, sy, sz = LibDraw.rotateZ(x, y, z, sx, sy, sz, rotationZ)
5532 ex, ey, ez = LibDraw.rotateZ(x, y, z, ex, ey, ez, rotationZ)
5533 end
5534
5535 local sx, sy = WorldToScreen(sx, sy, sz)
5536 local ex, ey = WorldToScreen(ex, ey, ez)
5537 LibDraw.Draw2DLine(sx, sy, ex, ey)
5538 end
5539 end
5540
5541 local LINEFACTOR = 256 / 254;
5542 local LINEFACTOR_2 = LINEFACTOR / 2;
5543
5544 function LibDraw.Draw2DLine(sx, sy, ex, ey)
5545 if not FireHack or not sx or not sy or not ex or not ey then return end
5546
5547 local T = tremove(LibDraw.textures) or false
5548 if T == false then
5549 T = LibDraw.canvas:CreateTexture(nil, "BACKGROUND")
5550 T:SetDrawLayer(LibDraw.level)
5551 end
5552
5553 T:SetTexture(LibDraw.texture)
5554 tinsert(LibDraw.textures_used, T)
5555
5556 -- Determine dimensions and center point of line
5557 local dx, dy = ex - sx, ey - sy
5558 local cx, cy = (sx + ex) * 0.5, (sy + ey) * 0.5
5559
5560 -- Normalize direction if necessary
5561 if (dx < 0) then
5562 dx, dy = -dx, -dy
5563 end
5564
5565 -- Calculate actual length of line
5566 local l = sqrt((dx * dx) + (dy * dy))
5567
5568 -- Quick escape if it's zero length
5569 if (l == 0) then
5570 T:SetTexCoord(0, 0, 0, 0, 0, 0, 0, 0)
5571 T:SetPoint("BOTTOMLEFT", C, "TOPLEFT", cx, cy)
5572 T:SetPoint("TOPRIGHT", C, "TOPLEFT", cx, cy)
5573 return
5574 end
5575
5576 -- Sin and Cosine of rotation, and combination (for later)
5577 local s, c = -dy / l, dx / l
5578 local sc = s * c
5579
5580 -- Calculate bounding box size and texture coordinates
5581 local Bwid, Bhgt, BLx, BLy, TLx, TLy, TRx, TRy, BRx, BRy
5582 if (dy >= 0) then
5583 Bwid = ((l * c) - (LibDraw.line.w * s)) * LINEFACTOR_2
5584 Bhgt = ((LibDraw.line.w * c) - (l * s)) * LINEFACTOR_2
5585 BLx, BLy, BRy = (LibDraw.line.w / l) * sc, s * s, (l / LibDraw.line.w) * sc
5586 BRx, TLx, TLy, TRx = 1 - BLy, BLy, 1 - BRy, 1 - BLx
5587 TRy = BRx;
5588 else
5589 Bwid = ((l * c) + (LibDraw.line.w * s)) * LINEFACTOR_2
5590 Bhgt = ((LibDraw.line.w * c) + (l * s)) * LINEFACTOR_2
5591 BLx, BLy, BRx = s * s, -(l / LibDraw.line.w) * sc, 1 + (LibDraw.line.w / l) * sc
5592 BRy, TLx, TLy, TRy = BLx, 1 - BRx, 1 - BLx, 1 - BLy
5593 TRx = TLy
5594 end
5595
5596 if TLx > 10000 then TLx = 10000 elseif TLx < -10000 then TLx = -10000 end
5597 if TLy > 10000 then TLy = 10000 elseif TLy < -10000 then TLy = -10000 end
5598 if BLx > 10000 then BLx = 10000 elseif BLx < -10000 then BLx = -10000 end
5599 if BLy > 10000 then BLy = 10000 elseif BLy < -10000 then BLy = -10000 end
5600 if TRx > 10000 then TRx = 10000 elseif TRx < -10000 then TRx = -10000 end
5601 if TRy > 10000 then TRy = 10000 elseif TRy < -10000 then TRy = -10000 end
5602 if BRx > 10000 then BRx = 10000 elseif BRx < -10000 then BRx = -10000 end
5603 if BRy > 10000 then BRy = 10000 elseif BRy < -10000 then BRy = -10000 end
5604
5605 T:ClearAllPoints()
5606
5607 -- Set texture coordinates and anchors
5608 T:SetTexCoord(TLx, TLy, BLx, BLy, TRx, TRy, BRx, BRy)
5609 T:SetPoint("BOTTOMLEFT", LibDraw.canvas, "TOPLEFT", cx - Bwid, cy - Bhgt)
5610 T:SetPoint("TOPRIGHT", LibDraw.canvas, "TOPLEFT", cx + Bwid, cy + Bhgt)
5611 T:SetVertexColor(LibDraw.line.r, LibDraw.line.g, LibDraw.line.b, LibDraw.line.a)
5612 T:Show()
5613
5614 end
5615
5616 local full_circle = rad(365)
5617 local small_circle_step = rad(3)
5618
5619 function LibDraw.Circle(x, y, z, size)
5620 local lx, ly, nx, ny, fx, fy = false, false, false, false, false, false
5621 for v = 0, full_circle, small_circle_step do
5622 nx, ny = WorldToScreen((x + cos(v) * size), (y + sin(v) * size), z)
5623 LibDraw.Draw2DLine(lx, ly, nx, ny)
5624 lx, ly = nx, ny
5625 end
5626 end
5627
5628 local flags = bit.bor(0x100)
5629
5630 function LibDraw.GroundCircle(x, y, z, size)
5631 local lx, ly, nx, ny, fx, fy, fz = false, false, false, false, false, false, false
5632 for v = 0, full_circle, small_circle_step do
5633 fx, fy, fz = TraceLine((x + cos(v) * size), (y + sin(v) * size), z + 100, (x + cos(v) * size), (y + sin(v) * size), z - 100, flags)
5634 if fx == nil then
5635 fx, fy, fz = (x + cos(v) * size), (y + sin(v) * size), z
5636 end
5637 nx, ny = WorldToScreen((fx + cos(v) * size), (fy + sin(v) * size), fz)
5638 LibDraw.Draw2DLine(lx, ly, nx, ny)
5639 lx, ly = nx, ny
5640 end
5641 end
5642
5643 function LibDraw.Arc(x, y, z, size, arc, rotation)
5644 local lx, ly, nx, ny, fx, fy = false, false, false, false, false, false
5645 local half_arc = arc * 0.5
5646 local ss = (arc / half_arc)
5647 local as, ae = -half_arc, half_arc
5648 for v = as, ae, ss do
5649 nx, ny = WorldToScreen((x + cos(rotation + rad(v)) * size), (y + sin(rotation + rad(v)) * size), z)
5650 if lx and ly then
5651 LibDraw.Draw2DLine(lx, ly, nx, ny)
5652 else
5653 fx, fy = nx, ny
5654 end
5655 lx, ly = nx, ny
5656 end
5657 local px, py = WorldToScreen(x, y, z)
5658 LibDraw.Draw2DLine(px, py, lx, ly)
5659 LibDraw.Draw2DLine(px, py, fx, fy)
5660 end
5661
5662 function LibDraw.Texture(config, x, y, z, alphaA)
5663
5664 local texture, width, height = config.texture, config.width, config.height
5665 local left, right, top, bottom, scale = config.left, config.right, config.top, config.bottom, config.scale
5666 local alpha = config.alpha or alphaA
5667
5668 if not FireHack or not texture or not width or not height or not x or not y or not z then return end
5669 if not left or not right or not top or not bottom then
5670 left = 0
5671 right = 1
5672 top = 0
5673 bottom = 1
5674 end
5675 if not scale then
5676 local cx, cy, cz = GetCameraPosition()
5677 scale = width / LibDraw.Distance(x, y, z, cx, cy, cz)
5678 end
5679
5680 local sx, sy = WorldToScreen(x, y, z)
5681 if not sx or not sy then return end
5682 local w = width * scale
5683 local h = height * scale
5684 sx = sx - w * 0.5
5685 sy = sy + h * 0.5
5686 local ex, ey = sx + w, sy - h
5687
5688 local T = tremove(LibDraw.textures) or false
5689 if T == false then
5690 T = LibDraw.canvas:CreateTexture(nil, "BACKGROUND")
5691 T:SetDrawLayer(LibDraw.level)
5692 T:SetTexture(LibDraw.texture)
5693 end
5694 tinsert(LibDraw.textures_used, T)
5695 T:ClearAllPoints()
5696 T:SetTexCoord(left, right, top, bottom)
5697 T:SetTexture(texture)
5698 T:SetWidth(width)
5699 T:SetHeight(height)
5700 T:SetPoint("TOPLEFT", LibDraw.canvas, "TOPLEFT", sx, sy)
5701 T:SetPoint("BOTTOMRIGHT", LibDraw.canvas, "TOPLEFT", ex, ey)
5702 T:SetVertexColor(1, 1, 1, 1)
5703 if alpha then T:SetAlpha(alpha) else T:SetAlpha(1) end
5704 T:Show()
5705
5706 end
5707
5708 function LibDraw.Text(text, font, x, y, z)
5709
5710 local sx, sy = WorldToScreen(x, y, z)
5711
5712 if sx and sy then
5713
5714 local F = tremove(LibDraw.fontstrings) or LibDraw.canvas:CreateFontString(nil, "BACKGROUND")
5715
5716 F:SetFontObject(font)
5717 F:SetText(text)
5718 F:SetTextColor(LibDraw.line.r, LibDraw.line.g, LibDraw.line.b, LibDraw.line.a)
5719
5720 if p then
5721 local width = F:GetStringWidth() - 4
5722 local offsetX = width * 0.5
5723 local offsetY = F:GetStringHeight() + 3.5
5724 local pwidth = width * p * 0.01
5725 FHAugment.drawLine(sx - offsetX, sy - offsetY, (sx + offsetX), sy - offsetY, 4, r, g, b, 0.25)
5726 FHAugment.drawLine(sx - offsetX, sy - offsetY, (sx + offsetX) - (width - pwidth), sy - offsetY, 4, r, g, b, 1)
5727 end
5728
5729 F:SetPoint("TOPLEFT", UIParent, "TOPLEFT", sx - (F:GetStringWidth() * 0.5), sy)
5730 F:Show()
5731
5732 tinsert(LibDraw.fontstrings_used, F)
5733
5734 end
5735
5736 end
5737
5738 local rad90 = math.rad(-90)
5739
5740 function LibDraw.Box(x, y, z, width, height, rotation, offset_x, offset_y)
5741
5742 if not offset_x then offset_x = 0 end
5743 if not offset_y then offset_y = 0 end
5744
5745 if rotation then rotation = rotation + rad90 end
5746
5747 local half_width = width * 0.5
5748 local half_height = height * 0.5
5749
5750 local p1x, p1y = LibDraw.rotateZ(x, y, z, x - half_width + offset_x, y - half_width + offset_y, z, rotation)
5751 local p2x, p2y = LibDraw.rotateZ(x, y, z, x + half_width + offset_x, y - half_width + offset_y, z, rotation)
5752 local p3x, p3y = LibDraw.rotateZ(x, y, z, x - half_width + offset_x, y + half_width + offset_y, z, rotation)
5753 local p4x, p4y = LibDraw.rotateZ(x, y, z, x - half_width + offset_x, y - half_width + offset_y, z, rotation)
5754 local p5x, p5y = LibDraw.rotateZ(x, y, z, x + half_width + offset_x, y + half_width + offset_y, z, rotation)
5755 local p6x, p6y = LibDraw.rotateZ(x, y, z, x + half_width + offset_x, y - half_width + offset_y, z, rotation)
5756 local p7x, p7y = LibDraw.rotateZ(x, y, z, x - half_width + offset_x, y + half_width + offset_y, z, rotation)
5757 local p8x, p8y = LibDraw.rotateZ(x, y, z, x + half_width + offset_x, y + half_width + offset_y, z, rotation)
5758
5759 LibDraw.Line(p1x, p1y, z, p2x, p2y, z)
5760 LibDraw.Line(p3x, p3y, z, p4x, p4y, z)
5761 LibDraw.Line(p5x, p5y, z, p6x, p6y, z)
5762 LibDraw.Line(p7x, p7y, z, p8x, p8y, z)
5763
5764 end
5765
5766 local deg45 = math.rad(45)
5767 local arrowX = {
5768 {0, 0, 0, 1.5, 0, 0},
5769 {1.5, 0, 0, 1.2, 0.2, -0.2},
5770 {1.5, 0, 0, 1.2, -0.2, 0.2}}
5771 local arrowY = {
5772 {0, 0, 0, 0, 1.5, 0},
5773 {0, 1.5, 0, 0.2, 1.2, -0.2},
5774 {0, 1.5, 0, -0.2, 1.2, 0.2}}
5775 local arrowZ = {
5776 {0, 0, 0, 0, 0, 1.5},
5777 {0, 0, 1.5, 0.2, -0.2, 1.2},
5778 {0, 0, 1.5, -0.2, 0.2, 1.2}}
5779
5780 function LibDraw.DrawHelper()
5781 local playerX, playerY, playerZ = ObjectPosition("player")
5782 local old_red, old_green, old_blue, old_alpha, old_width = LibDraw.line.r, LibDraw.line.g, LibDraw.line.b, LibDraw.line.a, LibDraw.line.w
5783
5784 -- X
5785 LibDraw.SetColor(255, 0, 0, 100)
5786 LibDraw.SetWidth(1)
5787 LibDraw.Array(arrowX, playerX, playerY, playerZ, deg45, false, false)
5788 LibDraw.Text('X', "GameFontNormal", playerX + 1.75, playerY, playerZ)
5789 -- Y
5790 LibDraw.SetColor(0, 255, 0, 100)
5791 LibDraw.SetWidth(1)
5792 LibDraw.Array(arrowY, playerX, playerY, playerZ, false, -deg45, false)
5793 LibDraw.Text('Y', "GameFontNormal", playerX, playerY + 1.75, playerZ)
5794 -- Z
5795 LibDraw.SetColor(0, 0, 255, 100)
5796 LibDraw.SetWidth(1)
5797 LibDraw.Array(arrowZ, playerX, playerY, playerZ, false, false, false)
5798 LibDraw.Text('Z', "GameFontNormal", playerX, playerY, playerZ + 1.75)
5799
5800 LibDraw.line.r, LibDraw.line.g, LibDraw.line.b, LibDraw.line.a, LibDraw.line.w = old_red, old_green, old_blue, old_alpha, old_width
5801 end
5802
5803 function LibDraw.Distance(ax, ay, az, bx, by, bz)
5804 return math.sqrt(((bx - ax) * (bx - ax)) + ((by - ay) * (by - ay)) + ((bz - az) * (bz - az)))
5805 end
5806
5807 function LibDraw.Camera()
5808 local fX, fY, fZ = ObjectPosition("player")
5809 local sX, sY, sZ = GetCameraPosition()
5810 return sX, sY, sZ, atan2(sY - fY, sX - fX), atan((sZ - fZ) / sqrt(((fX - sX) ^ 2) + ((fY - sY) ^ 2)))
5811 end
5812
5813 function LibDraw.Sync(callback)
5814 tinsert(LibDraw.callbacks, callback)
5815 end
5816
5817 function LibDraw.clearCanvas()
5818 LibDraw.stats = #LibDraw.textures_used
5819 for i = #LibDraw.textures_used, 1, -1 do
5820 LibDraw.textures_used[i]:Hide()
5821 tinsert(LibDraw.textures, tremove(LibDraw.textures_used))
5822 end
5823 for i = #LibDraw.fontstrings_used, 1, -1 do
5824 LibDraw.fontstrings_used[i]:Hide()
5825 tinsert(LibDraw.fontstrings, tremove(LibDraw.fontstrings_used))
5826 end
5827 end
5828
5829 local function OnUpdate()
5830 LibDraw.clearCanvas()
5831 for _, callback in ipairs(LibDraw.callbacks) do
5832 callback()
5833 if LibDraw.helper then
5834 LibDraw.DrawHelper()
5835 end
5836 LibDraw.helper = false
5837 end
5838 end
5839
5840 function LibDraw.Enable(interval)
5841 local timer
5842 if not interval then
5843 timer = C_Timer.NewTicker(interval, OnUpdate)
5844 else
5845 timer = C_Timer.NewTicker(interval, OnUpdate)
5846 end
5847 return timer
5848 end
5849
5850 end -- End of enableLibDraw
5851
5852 ----- REMOVE END
5853
5854 -- Timing = {}
5855
5856 -- DebugFunctions = { 'GetObjectCount', 'GetObjectWithGUID', 'GetObjectWithIndex', 'ObjectExists', 'ObjectPosition', 'TraceLine',
5857 -- 'ObjectTypeFlags', 'UnitCreator', 'IsHackEnabled', 'ObjectFacing', 'UnitCombatReach' }
5858
5859 -- for i, v in pairs(DebugFunctions) do
5860 -- Timing[v] = {
5861 -- Count = 0,
5862 -- TimePerCall = 0,
5863 -- Total = 0
5864 -- }
5865 -- end
5866
5867 -- for i, v in pairs(DebugFunctions) do
5868 -- local fName = v
5869 -- _G[fName .. '_Original'] = _G[fName]
5870 -- _G[fName] = function(...)
5871 -- local start = debugprofilestop()
5872 -- local ret1, ret2, ret3, ret4 = _G[fName .. '_Original'](...)
5873 -- Timing[fName]['Count'] = Timing[fName]['Count'] + 1
5874 -- Timing[fName]['Total'] = Timing[fName]['Total'] + (debugprofilestop() - start)
5875 -- Timing[fName]['TimePerCall'] = Timing[fName]['Total'] / Timing[fName]['Count']
5876 -- return ret1, ret2, ret3, ret4
5877 -- end
5878 -- end
5879
5880 -- local startDebug = debugprofilestop()
5881 -- handleTiming = function()
5882 -- local endDebug = debugprofilestop() - startDebug
5883 -- local overhead = 0
5884 -- for i, v in pairs(Timing) do
5885 -- overhead = overhead + v['Total']
5886 -- print(string.format('%s %d %.6f %.2f %.1f/s', i, v['Count'], v['TimePerCall'], v['Total'], v['Count']*1000/endDebug))
5887 -- end
5888 -- print(string.format("> End Debug %.2f %.2f%%", debugprofilestop() - startDebug, overhead*100/endDebug))
5889 -- end
5890
5891 -- testFunction = function()
5892 -- GetObjectCount()
5893 -- end
5894
5895 -- C_Timer.NewTicker(1.0, handleTiming)
5896
5897 -- C_Timer.NewTicker(0.1, testFunction)
5898 "]:1247:
5899 [string "EWT = {}..."]:1246
5900Locals: