mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-01 02:03:32 +00:00
Added spell channeling support
This commit is contained in:
parent
7341613f21
commit
3b28170217
@ -17,8 +17,9 @@ namespace Artemis.Modules.Games.WoW.Models
|
|||||||
public DateTime EndTime { get; set; }
|
public DateTime EndTime { get; set; }
|
||||||
public bool NonInterruptible { get; set; }
|
public bool NonInterruptible { get; set; }
|
||||||
public float Progress { get; set; }
|
public float Progress { get; set; }
|
||||||
|
public bool IsChannel { get; set; }
|
||||||
|
|
||||||
public void ApplyJson(JToken spellJson)
|
public void ApplyJson(JToken spellJson, bool isChannel)
|
||||||
{
|
{
|
||||||
var castMs = spellJson["e"].Value<int>() - spellJson["s"].Value<int>();
|
var castMs = spellJson["e"].Value<int>() - spellJson["s"].Value<int>();
|
||||||
var tickCount = Environment.TickCount;
|
var tickCount = Environment.TickCount;
|
||||||
@ -29,6 +30,7 @@ namespace Artemis.Modules.Games.WoW.Models
|
|||||||
StartTime = new DateTime(DateTime.Now.Ticks + difference);
|
StartTime = new DateTime(DateTime.Now.Ticks + difference);
|
||||||
EndTime = StartTime.AddMilliseconds(castMs);
|
EndTime = StartTime.AddMilliseconds(castMs);
|
||||||
NonInterruptible = spellJson["ni"].Value<bool>();
|
NonInterruptible = spellJson["ni"].Value<bool>();
|
||||||
|
IsChannel = isChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateProgress()
|
public void UpdateProgress()
|
||||||
@ -39,8 +41,12 @@ namespace Artemis.Modules.Games.WoW.Models
|
|||||||
var elapsed = DateTime.Now - StartTime;
|
var elapsed = DateTime.Now - StartTime;
|
||||||
var total = EndTime - StartTime;
|
var total = EndTime - StartTime;
|
||||||
|
|
||||||
|
if (IsChannel)
|
||||||
|
Progress = 1 - (float) (elapsed.TotalMilliseconds / total.TotalMilliseconds);
|
||||||
|
else
|
||||||
Progress = (float) (elapsed.TotalMilliseconds / total.TotalMilliseconds);
|
Progress = (float) (elapsed.TotalMilliseconds / total.TotalMilliseconds);
|
||||||
if (Progress > 1)
|
|
||||||
|
if (Progress > 1 || Progress < 0)
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +58,7 @@ namespace Artemis.Modules.Games.WoW.Models
|
|||||||
EndTime = DateTime.MinValue;
|
EndTime = DateTime.MinValue;
|
||||||
NonInterruptible = false;
|
NonInterruptible = false;
|
||||||
Progress = 0;
|
Progress = 0;
|
||||||
|
IsChannel = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ Artemis = LibStub("AceAddon-3.0"):NewAddon("Artemis", "AceConsole-3.0", "AceEven
|
|||||||
json = LibStub("json")
|
json = LibStub("json")
|
||||||
local debugging = false
|
local debugging = false
|
||||||
local lastLine = {}
|
local lastLine = {}
|
||||||
|
local channeling = {}
|
||||||
local unitUpdates = {}
|
local unitUpdates = {}
|
||||||
local lastTransmitMessage
|
local lastTransmitMessage
|
||||||
local lastTransmitTime
|
local lastTransmitTime
|
||||||
@ -9,6 +10,9 @@ local lastBuffs = "";
|
|||||||
local lastDebuffs = "";
|
local lastDebuffs = "";
|
||||||
local prefixCounts = {}
|
local prefixCounts = {}
|
||||||
|
|
||||||
|
channeling["player"] = false
|
||||||
|
channeling["target"] = false
|
||||||
|
|
||||||
function Artemis:OnEnable()
|
function Artemis:OnEnable()
|
||||||
Artemis:RegisterEvent("PLAYER_ENTERING_WORLD")
|
Artemis:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
Artemis:RegisterEvent("PLAYER_LEVEL_UP")
|
Artemis:RegisterEvent("PLAYER_LEVEL_UP")
|
||||||
@ -21,6 +25,10 @@ function Artemis:OnEnable()
|
|||||||
Artemis:RegisterEvent("UNIT_SPELLCAST_START")
|
Artemis:RegisterEvent("UNIT_SPELLCAST_START")
|
||||||
Artemis:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
|
Artemis:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
|
||||||
Artemis:RegisterEvent("UNIT_SPELLCAST_FAILED")
|
Artemis:RegisterEvent("UNIT_SPELLCAST_FAILED")
|
||||||
|
Artemis:RegisterEvent("UNIT_SPELLCAST_DELAYED")
|
||||||
|
Artemis:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
|
||||||
|
Artemis:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
|
||||||
|
Artemis:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE")
|
||||||
Artemis:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
|
Artemis:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
|
||||||
Artemis:RegisterEvent("ZONE_CHANGED")
|
Artemis:RegisterEvent("ZONE_CHANGED")
|
||||||
Artemis:RegisterEvent("ZONE_CHANGED_NEW_AREA")
|
Artemis:RegisterEvent("ZONE_CHANGED_NEW_AREA")
|
||||||
@ -166,6 +174,7 @@ function Artemis:UNIT_TARGET(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local details = Artemis:GetUnitDetails("target")
|
local details = Artemis:GetUnitDetails("target")
|
||||||
|
channeling["target"] = false
|
||||||
|
|
||||||
Artemis:Transmit("target", details)
|
Artemis:Transmit("target", details)
|
||||||
Artemis:TransmitUnitState("target", true);
|
Artemis:TransmitUnitState("target", true);
|
||||||
@ -232,6 +241,9 @@ function Artemis:UNIT_SPELLCAST_SUCCEEDED (...)
|
|||||||
if not (unitID == "player") and not (unitID == "target") then
|
if not (unitID == "player") and not (unitID == "target") then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if channeling[unitID] == true then
|
||||||
|
return
|
||||||
|
end
|
||||||
-- Many spells are irrelevant system spells, don't transmit these
|
-- Many spells are irrelevant system spells, don't transmit these
|
||||||
if unitID == "player" and not (IsPlayerSpell(spellID)) then
|
if unitID == "player" and not (IsPlayerSpell(spellID)) then
|
||||||
return
|
return
|
||||||
@ -270,6 +282,18 @@ function Artemis:UNIT_SPELLCAST_FAILED (...)
|
|||||||
Artemis:Transmit("spellCastFailed", unitID, "ALERT")
|
Artemis:Transmit("spellCastFailed", unitID, "ALERT")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Detect falure of non instant casts
|
||||||
|
function Artemis:UNIT_SPELLCAST_DELAYED (...)
|
||||||
|
local _, unitID, spell, rank, lineID, spellID = ...
|
||||||
|
if not (unitID == "player") and not (unitID == "target") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local name, _, _, _, startTime, endTime, _, _, notInterruptible = UnitCastingInfo(unitID)
|
||||||
|
local table = {uid = unitID, n = name, sid = spellID, s = startTime, e = endTime, ni = notInterruptible}
|
||||||
|
|
||||||
|
Artemis:Transmit("spellCast", table, "ALERT")
|
||||||
|
end
|
||||||
|
|
||||||
-- Detect cancellation of non instant casts
|
-- Detect cancellation of non instant casts
|
||||||
function Artemis:UNIT_SPELLCAST_INTERRUPTED (...)
|
function Artemis:UNIT_SPELLCAST_INTERRUPTED (...)
|
||||||
local source, unitID, _, _, lineID = ...
|
local source, unitID, _, _, lineID = ...
|
||||||
@ -285,6 +309,43 @@ function Artemis:UNIT_SPELLCAST_INTERRUPTED (...)
|
|||||||
Artemis:Transmit("spellCastInterrupted", unitID, "ALERT")
|
Artemis:Transmit("spellCastInterrupted", unitID, "ALERT")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Detect spell channels
|
||||||
|
function Artemis:UNIT_SPELLCAST_CHANNEL_START(...)
|
||||||
|
local _, unitID, spell, rank, lineID, spellID = ...
|
||||||
|
if not (unitID == "player") and not (unitID == "target") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
channeling[unitID] = true
|
||||||
|
|
||||||
|
local name, _, _, _, startTime, endTime, _, notInterruptible = UnitChannelInfo(unitID)
|
||||||
|
local table = {uid = unitID, n = name, sid = spellID, s = startTime, e = endTime, ni = notInterruptible}
|
||||||
|
|
||||||
|
Artemis:Transmit("spellChannel", table, "ALERT")
|
||||||
|
end
|
||||||
|
|
||||||
|
function Artemis:UNIT_SPELLCAST_CHANNEL_UPDATE (...)
|
||||||
|
local _, unitID, spell, rank, lineID, spellID = ...
|
||||||
|
if not (unitID == "player") and not (unitID == "target") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local name, _, _, _, startTime, endTime, _, notInterruptible = UnitChannelInfo(unitID)
|
||||||
|
local table = {uid = unitID, n = name, sid = spellID, s = startTime, e = endTime, ni = notInterruptible}
|
||||||
|
|
||||||
|
Artemis:Transmit("spellChannel", table, "ALERT")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Detect cancellation of channels
|
||||||
|
function Artemis:UNIT_SPELLCAST_CHANNEL_STOP (...)
|
||||||
|
local source, unitID, _, _, lineID = ...
|
||||||
|
if not (unitID == "player") and not (unitID == "target") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
channeling[unitID] = false
|
||||||
|
|
||||||
|
Artemis:Transmit("spellChannelInterrupted", unitID, "ALERT")
|
||||||
|
end
|
||||||
|
|
||||||
function Artemis:ZONE_CHANGED_NEW_AREA (...)
|
function Artemis:ZONE_CHANGED_NEW_AREA (...)
|
||||||
local pvpType, isSubZonePVP, factionName = GetZonePVPInfo()
|
local pvpType, isSubZonePVP, factionName = GetZonePVPInfo()
|
||||||
|
|
||||||
|
|||||||
@ -75,7 +75,7 @@ namespace Artemis.Modules.Games.WoW
|
|||||||
ParseAuras(json, dataModel, false);
|
ParseAuras(json, dataModel, false);
|
||||||
break;
|
break;
|
||||||
case "spellCast":
|
case "spellCast":
|
||||||
ParseSpellCast(json, dataModel);
|
ParseSpellCast(json, dataModel, false);
|
||||||
break;
|
break;
|
||||||
case "instantSpellCast":
|
case "instantSpellCast":
|
||||||
ParseInstantSpellCast(json, dataModel);
|
ParseInstantSpellCast(json, dataModel);
|
||||||
@ -86,6 +86,12 @@ namespace Artemis.Modules.Games.WoW
|
|||||||
case "spellCastInterrupted":
|
case "spellCastInterrupted":
|
||||||
ParseSpellCastInterrupted(data, dataModel);
|
ParseSpellCastInterrupted(data, dataModel);
|
||||||
break;
|
break;
|
||||||
|
case "spellChannel":
|
||||||
|
ParseSpellCast(json, dataModel, true);
|
||||||
|
break;
|
||||||
|
case "spellChannelInterrupted":
|
||||||
|
ParseSpellCastInterrupted(data, dataModel);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Logger.Warn("The WoW addon sent an unknown command: {0}", command);
|
Logger.Warn("The WoW addon sent an unknown command: {0}", command);
|
||||||
break;
|
break;
|
||||||
@ -118,12 +124,12 @@ namespace Artemis.Modules.Games.WoW
|
|||||||
dataModel.Player.ApplyAuraJson(json, buffs);
|
dataModel.Player.ApplyAuraJson(json, buffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseSpellCast(JToken json, WoWDataModel dataModel)
|
private void ParseSpellCast(JToken json, WoWDataModel dataModel, bool isChannel)
|
||||||
{
|
{
|
||||||
if (json["uid"].Value<string>() == "player")
|
if (json["uid"].Value<string>() == "player")
|
||||||
dataModel.Player.CastBar.ApplyJson(json);
|
dataModel.Player.CastBar.ApplyJson(json, isChannel);
|
||||||
else if (json["uid"].Value<string>() == "target")
|
else if (json["uid"].Value<string>() == "target")
|
||||||
dataModel.Target.CastBar.ApplyJson(json);
|
dataModel.Target.CastBar.ApplyJson(json, isChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseInstantSpellCast(JToken json, WoWDataModel dataModel)
|
private void ParseInstantSpellCast(JToken json, WoWDataModel dataModel)
|
||||||
|
|||||||
@ -84,6 +84,8 @@ namespace Artemis.Modules.Games.WoW
|
|||||||
|
|
||||||
// Split the string at the prefix
|
// Split the string at the prefix
|
||||||
var parts = str.Split(new[] {"(artemis)"}, StringSplitOptions.None);
|
var parts = str.Split(new[] {"(artemis)"}, StringSplitOptions.None);
|
||||||
|
if (parts.Length < 2)
|
||||||
|
return;
|
||||||
var msg = parts[1];
|
var msg = parts[1];
|
||||||
// Start escape char
|
// Start escape char
|
||||||
if (msg.StartsWith(MsgStart))
|
if (msg.StartsWith(MsgStart))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user