private static void ClearVerificationOlderThan(uint seconds) { if (_verification.Item1 != _emptyVerify.Item1 && _verification.Item4.AddSeconds(seconds) < DateTime.Now) { RotationLogger.Debug($"Force clearing verification because spell could not be verified for {seconds} seconds"); _verification = _emptyVerify; } }
public static void ForceClearVerification(string spellName) { lock (_verificationLock) { RotationLogger.Debug($"Force clearing verification for {spellName}"); _verification = _emptyVerify; } }
public static void QueueVerification(string spellName, WoWUnit target, RotationSpell.VerificationType type) { lock (_verificationLock) { RotationLogger.Debug($"Queueing verification for {spellName} on {Thread.CurrentThread.Name}"); _verification = new Tuple <string, ulong, RotationSpell.VerificationType, DateTime>(spellName, target.Guid, type, DateTime.Now); RegisterCombatLogClearer(); } }
public RotationSpellbook() { EventsLuaWithArgs.OnEventsLuaStringWithArgs += LuaEventHandler; _playerSpells.AddRange(GetSpellsFromLua()); _playerSpells.AddRange(GetSpellsFromLua("BOOKTYPE_PET")); foreach (var playerSpell in _playerSpells) { RotationLogger.Debug($"Fightclass framework found in spellbook: {playerSpell.Name} Rank {playerSpell.Rank}"); } }
public static void ForceClearVerification() { lock (_verificationLock) { if (_verification.Item1 != _emptyVerify.Item1) { RotationLogger.Debug($"Force clearing verification with current spell waiting on {_verification.Item1}"); _verification = _emptyVerify; } } }
public static void NotifyForDelegate(string id, List <string> args) { lock (_verificationLock) { if (!string.IsNullOrEmpty(_delegateVerification) && id == _delegateVerification && args[0] == "focus") { RotationLogger.Debug($"Clearing verification for {_verification.Item1} after delegated event {id}"); _verification = _emptyVerify; _delegateVerification = string.Empty; } } }
private void LuaEventHandler(string id, List <string> args) { if (id == "LEARNED_SPELL_IN_TAB") { RotationLogger.Debug($"Updating known spells because of {id}"); SpellUpdateHandler(); } if (id == "PET_BAR_UPDATE" && _lastUpdate.AddSeconds(1) < DateTime.Now) { _lastUpdate = DateTime.Now; RotationLogger.Debug($"Updating known spells because of {id}"); SpellUpdateHandler(); } }
/* * Example of NotifyForDelegate when usign COMBAT_TEXT_UPDATE instead of FocusUnit * * * public static void NotifyForDelegate(string id, List<string> args) * { * lock (VerificationLock) * { * if (_delegateVerification?.Count > 0 && id == "COMBAT_TEXT_UPDATE" && _delegateVerification.Contains(args[0])) * { * string eventName = args[0]; * string auraOrHealerName = args[1]; * * if (eventName.Contains("HEAL") && auraOrHealerName == RotationFramework.Me.Name) * { * Blindly.Run(() => * { * Thread.Sleep(Usefuls.Latency / 2); * RotationLogger.Debug($"Clearing verification for {_verification.Item1} after delegated event {eventName}"); * _verification = EmptyVerify; * _delegateVerification = new List<string>(); * }); * } * else if (eventName.Contains("AURA") && auraOrHealerName == _verification.Item1) * { * Blindly.Run(() => * { * Thread.Sleep(Usefuls.LatencyReal); * RotationLogger.Debug($"Clearing verification for {_verification.Item1} after delegated event {eventName}"); * _verification = EmptyVerify; * _delegateVerification = new List<string>(); * }); * * } * } * } * } */ public static void ClearIfOutOfRange() { lock (_verificationLock) { if (_verification.Item1 != _emptyVerify.Item1) { bool isInRange = RotationCombatUtil.ExecuteActionOnTarget( _verification.Item2, luaUnitId => Lua.LuaDoString <bool>($@" local spellInRange = IsSpellInRange(""{_verification.Item1}"", ""{luaUnitId}"") == 1; --DEFAULT_CHAT_FRAME:AddMessage(""Checking range of {_verification.Item1} on {luaUnitId} is "" .. (spellInRange and 'true' or 'false')); return spellInRange;") ); if (!isInRange && !RotationFramework.Me.IsCast) { RotationLogger.Debug($"Force clearing verification for {_verification.Item1} on {_verification.Item2} because we're out of range"); _verification = _emptyVerify; } } } }
public static void NotifyCombatLog(List <string> args) { lock (_verificationLock) { string timestamp = args[0]; string eventName = args[1]; string sourceGuid = args[2]; string sourceName = args[3]; string sourceFlags = args[4]; string destGuid = args[5]; string destName = args[6]; string destFlags = args[7]; // we have to check that the event fired is an expected event for the type of spell being casted // so that spells expecting an aura will only be verified on aura appliance RotationSpell.VerificationType type = GetVerificationType(); if (_successEvents[type].Contains(eventName)) { string spellId = args[8]; string spellName = args[9]; string spellSchool = args[10]; RotationLogger.Trace($"{eventName} {sourceGuid} {sourceName} {destGuid} {destName} {spellId} {spellName} {spellSchool}"); ulong castedBy = GetGUIDForLuaGUID(sourceGuid); if (castedBy == _playerGuid && IsSpellWaitingForVerification(spellName)) { var delegated = _eventDelegates.FirstOrDefault(e => e.Item1 == eventName); if (delegated != null) { string delegatedEvent = delegated.Item2; RotationLogger.Debug($"Delegating {eventName} to {delegatedEvent}"); CreatePassiveEventDelegate(delegatedEvent); } else { RotationLogger.Debug($"Clearing verification for {spellName}"); _verification = _emptyVerify; } } ulong spellTarget = GetGUIDForLuaGUID(destGuid); if (castedBy == 0 && IsWaitingForSpellOnTarget(spellName, spellTarget)) { var delegated = _eventDelegates.FirstOrDefault(e => e.Item1 == eventName); if (delegated != null) { string delegatedEvent = delegated.Item2; RotationLogger.Debug($"Delegating {eventName} to {delegatedEvent}"); CreatePassiveEventDelegate(delegatedEvent); } else { RotationLogger.Debug($"Clearing verification for spell with no source {spellName}"); _verification = _emptyVerify; } } } if (eventName == "SPELL_CAST_FAILED") { string spellId = args[8]; string spellName = args[9]; string spellSchool = args[10]; string failedType = args[11]; ulong castedBy = GetGUIDForLuaGUID(sourceGuid); if (castedBy == _playerGuid && IsSpellWaitingForVerification(spellName) && failedType != "Another action is in progress") { RotationLogger.Debug($"Clearing verification for {spellName} because {failedType}"); _verification = _emptyVerify; } } if (eventName == "UNIT_DIED") { ulong deadUnit = GetGUIDForLuaGUID(destGuid); if (IsWaitingOnTarget(deadUnit)) { RotationLogger.Debug($"Clearing verification because target died"); _verification = _emptyVerify; } if (deadUnit == _playerGuid) { RotationLogger.Debug($"Clearing verification because we died"); _verification = _emptyVerify; } } ClearVerificationOlderThan(10); } }