- Rework on Activity Time, now it will be more accurate with warcraftlogs.com

- Added two new customs: Damage Activity Time and Healing Activity Time.
- TimeAttack plugin now have only have six time amount options.
- TimeAttack plugin can now share damage results with other players with the same class in the realm.

- New API: instance:EnableInstance() active and open a closed instance.
- New API: _detalhes:RegisterBackgroundTask (name, func, priority, ...) background task runs slowly when player isn't in group nor inside instances.
- New API: _detalhes:UnregisterBackgroundTask (name) cancel a backgroup task.
- New API: plugin:RegisterPluginComm (prefix, func) register for receive comm msg.
- New API: plugin:UnregisterPluginComm (prefix) unregister a previous registred comm.
- New API: plugin:SendPluginCommMessage (prefix, channel, ...) send a msg through channel.
- New API: _detalhes:IsConnected() return true is Details! is connected to realm comm channel.
- New API: plugin:IsPluginEnabled() return is the plugin is enabled.
This commit is contained in:
tercio
2014-08-27 14:58:41 -03:00
parent ab51564def
commit be107afe52
16 changed files with 982 additions and 195 deletions
+62 -1
View File
@@ -141,4 +141,65 @@ function _detalhes:GetPerformanceRaidType()
end
return nil
end
end
local background_tasks = {}
local task_timers = {
["LOW"] = 30,
["MEDIUM"] = 18,
["HIGH"] = 10,
}
function _detalhes:RegisterBackgroundTask (name, func, priority, ...)
assert (type (self) == "table", "RegisterBackgroundTask 'self' must be a table.")
assert (type (name) == "string", "RegisterBackgroundTask param #1 must be a string.")
if (type (func) == "string") then
assert (type (self [func]) == "function", "RegisterBackgroundTask param #2 function not found on main object.")
else
assert (type (func) == "function", "RegisterBackgroundTask param #2 expect a function or function name.")
end
priority = priority or "LOW"
priority = string.upper (priority)
if (not task_timers [priority]) then
priority = "LOW"
end
if (background_tasks [name]) then
background_tasks [name].func = func
background_tasks [name].priority = priority
background_tasks [name].args = {...}
background_tasks [name].args_amt = select ("#", ...)
background_tasks [name].object = self
return
else
background_tasks [name] = {func = func, lastexec = time(), priority = priority, nextexec = time() + task_timers [priority] * 60, args = {...}, args_amt = select ("#", ...), object = self}
end
end
function _detalhes:UnregisterBackgroundTask (name)
background_tasks [name] = nil
end
function _detalhes:DoBackgroundTasks()
if (_detalhes:GetZoneType() ~= "none" or _detalhes:InGroup()) then
return
end
local t = time()
for taskName, taskTable in pairs (background_tasks) do
if (t > taskTable.nextexec) then
if (type (taskTable.func) == "string") then
taskTable.object [taskTable.func] (taskTable.object, unpack (taskTable.args, 1, taskTable.args_amt))
else
taskTable.func (unpack (taskTable.args, 1, taskTable.args_amt))
end
taskTable.nextexec = random (30, 120) + t + (task_timers [taskTable.priority] * 60)
end
end
end
_detalhes.background_tasks_loop = _detalhes:ScheduleRepeatingTimer ("DoBackgroundTasks", 120)
+97 -42
View File
@@ -257,67 +257,110 @@
--> register comm
function _detalhes:CommReceived (_, data, _, source)
local type, player, realm, dversion, arg6, arg7, arg8, arg9 = _select (2, _detalhes:Deserialize (data))
local prefix, player, realm, dversion, arg6, arg7, arg8, arg9 = _select (2, _detalhes:Deserialize (data))
if (_detalhes.debug) then
_detalhes:Msg ("(debug) network received:", type, "length:",string.len (data))
_detalhes:Msg ("(debug) network received:", prefix, "length:",string.len (data))
end
local func = _detalhes.network.functions [type]
local func = _detalhes.network.functions [prefix]
if (func) then
func (player, realm, dversion, arg6, arg7, arg8, arg9)
else
local t = plugins_registred [type]
if (t) then
func (player, realm, dversion, t[3], arg6, arg7, arg8, arg9)
func = plugins_registred [prefix]
if (func) then
func (player, realm, dversion, arg6, arg7, arg8, arg9)
else
_detalhes:Msg ("comm type not found:", type)
_detalhes:Msg ("comm prefix not found:", prefix)
end
end
end
_detalhes:RegisterComm ("DTLS", "CommReceived")
function _detalhes:RegisterPluginComm (name, prefix, func, version)
assert (type (name) == "string" and string.len (name) > 3, "RegisterPluginComm expects a string with at least 4 characters on #1 argument.")
assert (type (prefix) == "string" and string.len (prefix) == 2, "RegisterPluginComm expects a string with 2 characters on #2 argument.")
assert (type (func) == "function", "RegisterPluginComm expects a function on #3 argument.")
assert (plugins_registred [prefix] == nil, "Prefix " .. prefix .. " already in use.")
assert (_detalhes.network.functions [prefix] == nil, "Prefix " .. prefix .. " already in use.")
function _detalhes:RegisterPluginComm (prefix, func)
assert (type (prefix) == "string" and string.len (prefix) >= 2 and string.len (prefix) <= 4, "RegisterPluginComm expects a string with 2-4 characters on #1 argument.")
assert (type (func) == "function" or (type (func) == "string" and type (self [func]) == "function"), "RegisterPluginComm expects a function or function name on #2 argument.")
assert (plugins_registred [prefix] == nil, "Prefix " .. prefix .. " already in use 1.")
assert (_detalhes.network.functions [prefix] == nil, "Prefix " .. prefix .. " already in use 2.")
plugins_registred [prefix] = {func, name, version}
if (type (func) == "string") then
plugins_registred [prefix] = self [func]
else
plugins_registred [prefix] = func
end
return true
end
function _detalhes:UnregisterPluginComm (name)
local prefix
for p, t in _pairs (plugins_registred) do
if (t [2] == name) then
prefix = p
break
end
end
if (prefix) then
plugins_registred [prefix] = nil
end
function _detalhes:UnregisterPluginComm (prefix)
plugins_registred [prefix] = nil
return true
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> send functions
function _detalhes:SendPluginCommMessage (name, channel, ...)
local prefix
for p, t in _pairs (plugins_registred) do
if (t [2] == name) then
prefix = p
break
function _detalhes:GetChannelId (channel)
for id = 1, GetNumDisplayChannels() do
local name, _, _, room_id = GetChannelDisplayInfo (id)
if (name == channel) then
return room_id
end
end
if (prefix) then
end
function _detalhes.parser_functions:CHAT_MSG_CHANNEL (...)
local message, _, _, _, _, _, _, _, channelName = ...
if (channelName == "Details") then
local prefix, data = strsplit ("_", message, 2)
else
self:Msg ("comm not registred:", name)
local func = plugins_registred [prefix]
if (func) then
func (_select (2, _detalhes:Deserialize (data)))
else
_detalhes:Msg ("comm prefix not found:", prefix)
end
end
end
function _detalhes:SendPluginCommMessage (prefix, channel, ...)
if (not _detalhes:IsConnected()) then
return false
end
if (not channel) then
channel = "Details"
end
if (channel == "RAID") then
if (IsInGroup (LE_PARTY_CATEGORY_INSTANCE) and IsInInstance()) then
_detalhes:SendCommMessage (prefix, _detalhes:Serialize (self.__version, ...), "INSTANCE_CHAT")
else
_detalhes:SendCommMessage (prefix, _detalhes:Serialize (self.__version, ...), "RAID")
end
elseif (channel == "PARTY") then
if (IsInGroup (LE_PARTY_CATEGORY_INSTANCE) and IsInInstance()) then
_detalhes:SendCommMessage (prefix, _detalhes:Serialize (self.__version, ...), "INSTANCE_CHAT")
else
_detalhes:SendCommMessage (prefix, _detalhes:Serialize (self.__version, ...), "PARTY")
end
elseif (channel == "Details") then
local id = _detalhes:GetChannelId (channel)
if (id) then
SendChatMessage (prefix .. "_" .. _detalhes:Serialize (self.__version, ...), "CHANNEL", nil, id)
end
else
_detalhes:SendCommMessage (prefix, _detalhes:Serialize (self.__version, ...), channel)
end
return true
end
--> send as
function _detalhes:SendRaidDataAs (type, player, realm, ...)
@@ -428,17 +471,20 @@
local realm = GetRealmName()
realm = realm or ""
if (realm ~= "Azralon") then
return
end
--if (realm ~= "Azralon") then
-- return
--end
--> room name
local room_name = "Details"
_detalhes.listener:RegisterEvent ("CHAT_MSG_CHANNEL")
--> already in?
for room_index = 1, 10 do
local _, name = GetChannelName (room_index)
if (name == room_name) then
_detalhes.is_connected = true
return --> already in the room
end
end
@@ -446,6 +492,7 @@
--> enter
--print ("entrando no canal")
JoinChannelByName (room_name)
_detalhes.is_connected = true
end
function _detalhes:LeaveChatChannel()
@@ -459,13 +506,14 @@
local realm = GetRealmName()
realm = realm or ""
if (realm ~= "Azralon") then
return
end
--if (realm ~= "Azralon") then
-- return
--end
--> room name
local room_name = "Details"
local is_in = false
--> already in?
for room_index = 1, 10 do
local _, name = GetChannelName (room_index)
@@ -478,6 +526,10 @@
--print ("saindo do canal")
LeaveChannelByName (room_name)
end
_detalhes.is_connected = false
_detalhes.listener:UnregisterEvent ("CHAT_MSG_CHANNEL")
end
--> sair do canal quando estiver em grupo
@@ -538,4 +590,7 @@
_detalhes:RegisterEvent (event_handler, "GROUP_ONENTER", "GROUP_ONENTER")
_detalhes:RegisterEvent (event_handler, "GROUP_ONLEAVE", "GROUP_ONLEAVE")
_detalhes:RegisterEvent (event_handler, "ZONE_TYPE_CHANGED", "ZONE_TYPE_CHANGED")
function _detalhes:IsConnected()
return _detalhes.is_connected
end
+20 -6
View File
@@ -327,21 +327,21 @@
if (not este_jogador.dps_started) then
este_jogador:Iniciar (true)
este_jogador:Iniciar (true) --registra na timemachine
if (meu_dono and not meu_dono.dps_started) then
meu_dono:Iniciar (true)
if (meu_dono.end_time) then
meu_dono.end_time = nil
else
meu_dono:IniciarTempo (_tempo-2.5, meu_dono.shadow)
meu_dono:IniciarTempo (_tempo, meu_dono.shadow)
end
end
if (este_jogador.end_time) then
este_jogador.end_time = nil
else
este_jogador:IniciarTempo (_tempo-2.5, este_jogador.shadow)
este_jogador:IniciarTempo (_tempo, este_jogador.shadow)
end
if (este_jogador.nome == _detalhes.playername and token ~= "SPELL_PERIODIC_DAMAGE") then --> iniciando o dps do "PLAYER"
@@ -678,12 +678,22 @@
--> timer
if (not este_jogador.iniciar_hps) then
este_jogador:Iniciar (true) --inicia o dps do jogador
este_jogador:Iniciar (true) --inicia o hps do jogador
if (meu_dono and not meu_dono.dps_started) then
meu_dono:Iniciar (true)
if (meu_dono.end_time) then
meu_dono.end_time = nil
else
meu_dono:IniciarTempo (_tempo, meu_dono.shadow)
end
end
if (este_jogador.end_time) then --> o combate terminou, reabrir o tempo
este_jogador.end_time = nil
este_jogador.shadow.end_time = nil --> não tenho certeza se isso aqui não pode dar merda
else
este_jogador:IniciarTempo (_tempo-3.0, este_jogador.shadow)
este_jogador:IniciarTempo (_tempo, este_jogador.shadow)
end
end
@@ -735,6 +745,10 @@
este_alvo.total = este_alvo.total + cura_efetiva
end
if (meu_dono) then
meu_dono.last_event = _tempo
end
if (overhealing > 0) then
este_jogador.totalover = este_jogador.totalover + overhealing
este_alvo.overheal = este_alvo.overheal + overhealing
+11
View File
@@ -19,6 +19,17 @@
return _detalhes.plugin_database [PluginAbsoluteName]
end
function _detalhes:IsPluginEnabled (PluginAbsoluteName)
if (PluginAbsoluteName) then
local plugin = _detalhes.plugin_database [PluginAbsoluteName]
if (plugin) then
return plugin.__enabled
end
else
return self.__enabled
end
end
function _detalhes:CheckDefaultTable (current, default)
for key, value in pairs (default) do
if (type (value) == "table") then
+53 -51
View File
@@ -17,6 +17,7 @@
local _ipairs = ipairs --lua local
local _pairs = pairs --lua local
local _time = time --lua local
local _math_floor = math.floor
local timeMachine = _detalhes.timeMachine --details local
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -37,16 +38,13 @@
for tipo, tabela in _pairs (self.tabelas) do
for nome, jogador in _ipairs (tabela) do
if (jogador) then
local ultima_acao = jogador.last_event+10
if (ultima_acao > _tempo) then --> okey o jogador esta dando dps
if (jogador.last_event+10 > _tempo) then --> okey o jogador esta dando dps
if (jogador.on_hold) then --> o dps estava pausado, retornar a ativa
jogador:HoldOn (false)
end
else
if (not jogador.on_hold) then --> não ta pausado, precisa por em pausa
--> verifica se esta castando alguma coisa que leve + que 3 segundos
--> verifica se esta castando alguma coisa que leve + que 10 segundos
jogador:HoldOn (true)
end
end
@@ -131,11 +129,32 @@
function _detalhes:Tempo()
if (self.end_time) then --> o tempo do jogador esta trancado
return self.end_time - self.start_time
local t = self.end_time - self.start_time
if (t < 10) then
t = 10
end
return t
elseif (self.on_hold) then --> o tempo esta em pausa
return self.delay - self.start_time
local t = self.delay - self.start_time
if (t < 10) then
t = 10
end
return t
else
return _tempo - self.start_time
if (self.start_time == 0) then
return 10
end
local t = _tempo - self.start_time
if (t < 10) then
if (_detalhes.in_combat) then
local combat_time = _detalhes.tabela_vigente:GetCombatTime()
if (combat_time < 10) then
return combat_time
end
end
t = 10
end
return t
end
end
@@ -144,73 +163,56 @@
-- inicia o tempo no objeto atual
--------------------------------------------------------------------------------
if (self.start_time > 0) then
print ("DEBUG: "..self.name.." ja tinha start_time...")
else
self.start_time = tempo
end
self.start_time = tempo
-- inicia o tempo no shadow do objeto
--------------------------------------------------------------------------------
if (shadow.end_time) then
-- tempo do inicio da shadow = tempo de abertura ATUAL menos tempo de combate da shadow
local subs = shadow.end_time - shadow.start_time
shadow.start_time = tempo - subs
shadow.end_time = nil -- o tempo foi aberto retirando o end_time
--if (self.nome == "Ditador") then print ("shadow ja itnha end_time") end
else -- pela minha logica se nao tiver end_time significa que precisa apenas gravar o tempo de inicio
-- a shadow foi recém criada e esta abrindo o tempo pela primeira vez
if (shadow.start_time == 0) then --> ja esta em um combate
shadow.end_time = nil
else
if (shadow.start_time == 0) then
shadow.start_time = tempo
--if (self.nome == "Ditador") then print ("shadom sem end_time com start_time == 0") end
else
--if (self.nome == "Ditador") then print ("shadom sem end_time") end
end
end
end
function _detalhes:TerminarTempo (subs)
function _detalhes:TerminarTempo()
if (self.end_time) then
return
end
subs = subs or 0
if (self.on_hold) then
self.end_time = self.delay - subs -- isso ta certo? por que self.delay carrega o tempo quando o jogador parou o dps
self.on_hold = false
self.delay = nil
else
self.end_time = _tempo - subs
end
if (self.shadow) then
return self.shadow:TerminarTempo (subs)
self:HoldOn (false)
end
self.end_time = _tempo
end
--> diz se o dps deste jogador esta em pausa
function _detalhes:HoldOn (pausa)
--if (self.nome == "Ditador") then print ("colocando em hold on") end
if (pausa == nil) then
return self.on_hold --retorna se o dps esta aberto ou fechado para este jogador
elseif (pausa) then --> true
self.delay = _tempo
elseif (pausa) then --> true - colocar como inativo
self.delay = _math_floor (self.last_event) --_tempo - 10
if (self.delay < self.start_time) then
self.delay = self.start_time
end
self.on_hold = true
else --> false
self.start_time = self.start_time + (_tempo-self.delay)
else --> false - retornar a atividade
local diff = _tempo - self.delay - 1
if (diff > 0) then
self.start_time = self.start_time + diff
end
--if (_tempo - self.start_time < 20) then
-- self.start_time = self.start_time - 1
--end
self.on_hold = false
end
end
--controla quando foi a ultima vez que este jogador deu dano
function _detalhes:UltimaAcao (tempo)
if (not tempo) then
return self.last_event
else
self.last_event = tempo
end
end