Good day all!
I've found a lua script, which checks up for LoS and make delay before next cast, here it is:
Code:
if not tLOS then tLOS={} end
if not fLOS then fLOS=CreateFrame("Frame") end
delay = 1
function LineOfSight(target)
fLOS:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
function fLOSOnEvent(self,event,...)
if event=="COMBAT_LOG_EVENT_UNFILTERED" then
local cLOG={...}
if cLOG and cLOG[2] and cLOG[2]=="SPELL_CAST_FAILED" then
local player=UnitGUID("player") or ""
if cLOG[4] and cLOG[4]==player then
if cLOG[15] then
if cLOG[15]==SPELL_FAILED_LINE_OF_SIGHT
or cLOG[15]==SPELL_FAILED_NOT_INFRONT
or cLOG[15]==SPELL_FAILED_OUT_OF_RANGE
or cLOG[15]==SPELL_FAILED_UNIT_NOT_INFRONT
or cLOG[15]==SPELL_FAILED_UNIT_NOT_BEHIND
or cLOG[15]==SPELL_FAILED_NOT_BEHIND
or cLOG[15]==SPELL_FAILED_MOVING
or cLOG[15]==SPELL_FAILED_IMMUNE
or cLOG[15]==SPELL_FAILED_FLEEING
or cLOG[15]==SPELL_FAILED_BAD_TARGETS
or cLOG[15]==SPELL_FAILED_STUNNED
or cLOG[15]==SPELL_FAILED_SILENCED
or cLOG[15]==SPELL_FAILED_NOT_IN_CONTROL
then
tinsert(tLOS,{unit=target,time=GetTime()})
end
end
end
else
if #tLOS > 0 then
table.sort(tLOS,function(x,y) return x.time>y.time end)
for i=1,#tLOS do
local time=tLOS[i].time or GetTime()
if GetTime()>time+delay then
tremove(tLOS,i)
end
end
end
end
end
end
fLOS:SetScript("OnEvent",fLOSOnEvent)
if #tLOS > 0 then
for i=1,#tLOS do
if tLOS and tLOS[i] and tLOS[i].unit==target
then
return true
end
end
end
end
Sometimes it shows errors:
Code:
Message: Interface\AddOns\WowAddon4\Frame.lua:87: attempt to index field '?' (a nil value)
Time: 11/13/16 03:10:23
Count: 2
Stack: Interface\AddOns\WowAddon4\Frame.lua:87: in function <Interface\AddOns\WowAddon4\Frame.lua:58>
Locals: self = <unnamed> {
0 = <userdata>
}
event = "COMBAT_LOG_EVENT_UNFILTERED"
cLOG = <table> {
1 = 1478995822.928
2 = "SPELL_PERIODIC_HEAL"
3 = false
4 = "Pet-0-1-0-0-69947-00000061D5"
5 = "Spirit Beast"
6 = 4369
7 = 0
8 = "Player-1-0004DE7A"
9 = "Старкэ-x100"
10 = 1297
11 = 0
12 = 90361
13 = "Духовное лечение"
14 = 8
15 = 11103
16 = 0
17 = 0
18 = true
19 = false
}
(for index) = 2
(for limit) = 2
(for step) = 1
i = 2
(*temporary) = nil
(*temporary) = <function> defined =[C]:-1
(*temporary) = <table> {
1 = <table> {
}
}
(*temporary) = 1
(*temporary) = "attempt to index field '?' (a nil value)"
87 line is local time=tLOS[i].time or GetTime()
Can anybody help me what is wrong?