Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not DTPS_EventFrame then
- DTPS_EventFrame = CreateFrame("Frame")
- DamageTable={}
- TimestampTable={}
- end
- DTPS_EventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
- DTPS_EventFrame:SetScript("OnEvent", function(self, event, ...)
- if event == "COMBAT_LOG_EVENT_UNFILTERED" then
- DTPS_HandleCombatEvent(...)
- end
- end)
- function DTPS_HandleCombatEvent(timestamp, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23, arg24,...)
- i=0
- sum=0
- calc=0
- dtps=0
- iconvalue=0
- playerhealth=0
- durationdamage = 0
- damage=0
- n=0
- period = 5
- -- Check if it is the player who receives damage
- if arg8 ~= UnitGUID("player") then
- do return end
- end
- -- Sort out all events that are not damage
- if arg2 ~= "SWING_DAMAGE" then
- if arg2 ~= "RANGE_DAMAGE" then
- if arg2 ~= "SPELL_DAMAGE" then
- if arg2 ~= "SPELL_PERIODIC_DAMAGE" then
- if arg2 ~= "SPELL_BUILDING_DAMAGE" then
- if arg2 ~= "ENVIRONMENTAL_DAMAGE" then
- do return end
- end
- end
- end
- end
- end
- end
- -- Define the argument depending on damage
- if arg2 == "SWING_DAMAGE" then
- damage = arg12
- elseif arg2 == "RANGE_DAMAGE" or "SPELL_DAMAGE" or "SPELL_PERIODIC_DAMAGE" or "SPELL_BUILDING_DAMAGE" then
- damage = arg15
- elseif arg2 == "ENVIRONMENTAL_DAMAGE" then
- damage = arg13
- end
- --Check if the table is empty and fill the first entry
- if #TimestampTable == 0 then
- DamageTable[1]=damage
- TimestampTable[1]=timestamp
- i = 1
- else
- -- If table is not empty - add a new value to the beginning
- for i=#TimestampTable, 1, -1 do
- n = i+1
- TimestampTable[n] = TimestampTable[i]
- TimestampTable[1] = timestamp
- DamageTable[n] = DamageTable[i]
- DamageTable[1] = damage
- end
- -- Delete outdated values in the end
- for i=1, #TimestampTable do
- if TimestampTable[i] + period < timestamp then
- DamageTable[i] = nil
- TimestampTable[i] = nil
- end
- end
- -- Creating damage sum and values for icons
- sum = 0
- for i = 1, #TimestampTable do
- sum=sum+DamageTable[i]
- end
- -- Defining the duration of damage
- if TimestampTable[1] == TimestampTable[#TimestampTable] then
- durationdamage = 1
- else
- durationdamage = TimestampTable[1] - TimestampTable[#TimestampTable]
- end
- dtps = sum/durationdamage
- playerhealth = UnitHealthMax("player")
- iconvalue = dtps/playerhealth
- -- Icons values section
- if iconvalue > 0 then
- IC1 = true
- else
- IC1 = false
- end
- if iconvalue > 0.05 then
- IC2 = true
- else
- IC2 = false
- end
- if iconvalue > 0.1 then
- IC3 = true
- else
- IC3 = false
- end
- if iconvalue > 0.15 then
- IC4 = true
- else
- IC4 = false
- end
- if iconvalue > 0.2 then
- IC5 = true
- else
- IC5 = false
- end
- if iconvalue > 0.25 then
- IC6 = true
- else
- IC6 = false
- end
- if iconvalue > 0.3 then
- IC7 = true
- else
- IC7 = false
- end
- if iconvalue > 0.35 then
- IC8 = true
- else
- IC8 = false
- end
- if iconvalue > 0.4 then
- IC9 = true
- else
- IC9 = false
- end
- if iconvalue > 0.45 then
- IC10 = true
- else
- IC10 = false
- end
- if iconvalue > 0.5 then
- IC11 = true
- else
- IC11 = false
- end
- if iconvalue > 0.55 then
- IC12 = true
- else
- IC12 = false
- end
- if iconvalue > 0.6 then
- IC13 = true
- else
- IC13 = false
- end
- if iconvalue > 0.65 then
- IC14 = true
- else
- IC14 = false
- end
- if iconvalue > 0.7 then
- IC15 = true
- else
- IC15 = false
- end
- if iconvalue > 0.75 then
- IC16 = true
- else
- IC16 = false
- end
- if iconvalue > 0.8 then
- IC17 = true
- else
- IC17 = false
- end
- if iconvalue > 0.85 then
- IC18 = true
- else
- IC18 = false
- end
- if iconvalue > 0.9 then
- IC19 = true
- else
- IC19 = false
- end
- if iconvalue > 0.95 then
- IC20 = true
- else
- IC20 = false
- end
- SendChatMessage(durationdamage, "WHISPER", nil , "Zakdh")
- SendChatMessage(TimestampTable[1], "WHISPER", nil , "Zakdh")
- SendChatMessage(TimestampTable[#TimestampTable], "WHISPER", nil , "Zakdh")
- SendChatMessage(sum, "WHISPER", nil , "Zakdh")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement