01/07/09, 8:25 AM
|
#1
|
|
Sledgehammer Emeritus
|
Infraction for hisaku: General Idiocy
Post: Dots and you: The Affliction Warlock Thread
User: hisaku
Infraction: General Idiocy
Points: 1
Administrative Note:
Message to User:
Original Post:

Im interested in trying this code you wrote, but I've never done anything like this. How would I go about using it?

Originally Posted by Ravelvan
The only problem with this method is that you are forced to simply react to an event, instead of being able to foresee it. What I did was both use the above method, as well as created four kgPanels that marked tick locations on my casting bar. I then created scripts that would cause these marking to move when I received spell knock back, so that they would always be accurate.
This is the first ever attempt at any Lua coding or scripting I have ever attempted, so I am sure it is extremely poorly written, but this is what worked for me:
OnLoad:
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE")
self:RegisterEvent("COMBAT_LOG_EVENT")
self:Hide()
OnEvent:
if arg1 == "player" and arg2 == "Drain Soul" then
if event == "UNIT_SPELLCAST_CHANNEL_START" then
self:SetPoint("CENTER",UIParent,"CENTER",xxx,yyy)
_, _, _, _, startTimeOrig, _, _ = UnitChannelInfo("player")
panel###TickCount = 0
self:Show()
elseif event == "UNIT_SPELLCAST_CHANNEL_STOP" then
self:Hide()
elseif event == "UNIT_SPELLCAST_CHANNEL_UPDATE" then
local _, _, _, _, startTimeNew, endTimeNew, _ = UnitChannelInfo("player")
local pixelShift = aaa / ((endTimeNew - startTimeNew) / %%%) * (startTimeNew - startTimeOrig)
if pixelShift < -aaa * ### then
self:Hide()
else
self:SetPoint("CENTER",UIParent,"CENTER",pixelShift + xxx,yyy)
end
end
elseif event == "COMBAT_LOG_EVENT" and arg2 == "SPELL_PERIODIC_DAMAGE" and arg4 == "Ravelvan" and arg10 == "Drain Soul" then
panel###TickCount = 1 + panel###TickCount
if panel###TickCount >= $$$ then
self:Hide()
end
end
yyy is the y-offset for the panel.
xxx is the x-offset for the panel in its original, un-knockedback tick location.*
aaa is the number of pixels representing one-fifth of the cast bar.
### is the number of the panel counted from left to right.*
$$$ is the number of the panel counted from right to left.*
%%% is the total number of ticks you would expect if you don't get knocked back.
Ravelvan is your toons name. For some reason using "player" would not work here.
* Different for each of the 4 panels.
|
|
|
|
|
|
|