Example #1
0
        /// <summary>
        /// Get Units casting Info, example check if we can interrupt it or something alike
        /// </summary>
        /// <param name="player">LuaUnit to check</param>
        /// <returns>CastingInfo containing spellname, castEndTime and canInterrupt</returns>
        public static CastingInfo GetUnitCastingInfo(LuaUnit luaunit)
        {
            CastingInfo info = new CastingInfo();
            string      cmd  = $"abCastingInfo = \"none,0\"; abSpellName, x, x, x, x, abSpellEndTime = UnitCastingInfo(\"{luaunit.ToString()}\"); abDuration = ((abSpellEndTime/1000) - GetTime()) * 1000; abCastingInfo = abSpellName..\",\"..abDuration;";
            string      str  = GetLocalizedText(cmd, "abCastingInfo");

            info.name     = str.Split(',')[0];
            info.duration = Utils.TryParseInt(str.Split(',')[1]);

            AmeisenLogger.Instance.Log(LogLevel.DEBUG, $"[CastingInfo] Name: {info.name}, Duration: {info.duration} ms", "AmeisenCore");
            return(info);
        }
Example #2
0
        /// <summary>
        /// Get Units casting Info, example check if we can interrupt it or if Unit is casting
        /// </summary>
        /// <param name="player">LuaUnit to check</param>
        /// <returns>CastingInfo: spellname, castEndTime, canInterrupt</returns>
        public static CastingInfo GetUnitCastingInfo(LuaUnit player)
        {
            CastingInfo info = new CastingInfo();

            string cmd = $"name, _, _, _, _, endTime _, _, canInterrupt = UnitCastingInfo(\"{player}\");";

            try { info.name = GetLocalizedText(cmd, "name"); } catch { info.name = "none"; }
            try { info.endTime = int.Parse(GetLocalizedText(cmd, "endTime")); } catch { info.endTime = -1; }
            try { info.canInterrupt = bool.Parse(GetLocalizedText(cmd, "canInterrupt")); } catch { info.canInterrupt = false; }

            AmeisenLogger.Instance.Log(LogLevel.DEBUG, $"CastingInfo: [{info.name},{info.endTime},{info.canInterrupt}]", "AmeisenCore");

            return(info);
        }