Ejemplo n.º 1
0
        internal CaseInput(List <string> lines)
        {
            this.lines = lines;
            N          = int.Parse(lines[0]);
            var funs    = lines[1].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
            var targets = lines[2].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

            for (int arrayIndex = 0; arrayIndex < N; arrayIndex++)
            {
                var targetGraphModule = targets[arrayIndex] > 0 ? Modules[targets[arrayIndex]] : null;

                var newGraphModule = new GraphModule
                {
                    Id     = arrayIndex + 1,
                    Fun    = funs[arrayIndex],
                    Target = targetGraphModule
                };

                targetGraphModule?.Triggers.Add(newGraphModule);
                Modules.Add(arrayIndex + 1, newGraphModule);
            }

            foreach (var module in Modules.Values)
            {
                if (module.Target == null)
                {
                    AbyssalModules.Add(module);
                }

                if (!module.Triggers.Any())
                {
                    Initiators.Add(module);
                }
            }
        }
Ejemplo n.º 2
0
        private static void Game_OnUpdate(EventArgs args)
        {
            if (!_loaded)
            {
                _me     = ObjectMgr.LocalHero;
                _player = ObjectMgr.LocalPlayer;
                if (!Game.IsInGame || _me == null)
                {
                    return;
                }
                _loaded = true;
                PrintSuccess(string.Format("> AutoDisable Loaded v{0}", Ver));
            }
            if (!Game.IsInGame || _me == null)
            {
                _loaded = false;
                PrintInfo("> AutoDisable unLoaded");
                return;
            }

            uint i;

            for (i = 0; i < 10; i++)
            {
                try
                {
                    var v = ObjectMgr.GetPlayerById(i).Hero;
                    if (v == null || v.Team == _me.Team || Equals(v, _me) || !v.IsAlive || !v.IsVisible ||
                        !Utils.SleepCheck(v.GetHashCode().ToString()))
                    {
                        continue;
                    }
                    var isInvul      = v.IsInvul();
                    var magicImmnune = v.IsMagicImmune();
                    //var LinkProt = v.LinkProtection();
                    var isStun      = v.IsStunned();
                    var isHex       = v.IsHexed();
                    var isSilence   = v.IsSilenced();
                    var isDisarm    = v.IsDisarmed();
                    var isInvis     = _me.IsInvisible();
                    var isChannel   = _me.IsChanneling();
                    var items       = _me.Inventory.Items.Where(x => x.CanBeCasted());
                    var spells      = _me.Spellbook.Spells.Where(x => x.CanBeCasted());
                    var blink       = v.FindItem("item_blink");
                    var forcestaff  = v.FindItem("item_force_staff");
                    var dpActivated =
                        v.Modifiers.Any(
                            x => x.Name == "modifier_slark_dark_pact" || x.Name == "modifier_slark_dark_pact_pulses");
                    var enumerable = items as IList <Item> ?? items.ToList();
                    var distance   = _me.Distance2D(v);
                    //var angle =
                    string spellString;
                    var    angle = (float)(Math.Max(
                                               Math.Abs(v.RotationRad - Utils.DegreeToRadian(v.FindAngleBetween(_me.Position))) - 0.20, 0));

                    if (!enumerable.Any() || (isInvul || magicImmnune || isInvis || isChannel || dpActivated))
                    {
                        if ((blink != null && blink.Cooldown > 11) || forcestaff != null && forcestaff.Cooldown > 18.6)
                        {
                            UseDisableStageOne(v, enumerable, null, false);
                        }
                        else if (_activated)
                        {
                            UseDisableStageOne(v, enumerable, null, false);
                        }
                        else if (Initiators.TryGetValue(v.ClassID, out spellString))
                        {
                            var initSpell = v.FindSpell(spellString);
                            if (initSpell != null && initSpell.Cooldown != 0)
                            {
                                UseDisableStageOne(v, enumerable, null, false);
                            }
                        }
                    }
                    if (isStun || isHex || isSilence || isDisarm)
                    {
                        continue;
                    }
                    var abilities = spells as IList <Ability> ?? spells.ToList();
                    if (!abilities.Any() && !enumerable.Any())
                    {
                        continue;
                    }
                    //var

                    /*if (v.ClassID == ClassID.CDOTA_Unit_Hero_Clinkz)
                     * {
                     *  PrintError(String.Format("{0}", angle));
                     * }*/
                    if (angle == 0 && distance < 1500)
                    {
                        var r  = CheckForFirstSpell(v);
                        var r2 = CheckForSecondSpell(v);
                        //PrintError("kek");
                        var mustHave = false;
                        //PrintError("kek2");
                        var s = CheckForModifier(v, ref mustHave);
                        //PrintError("kek3");
                        var act = (CheckForNetworkAct(v) == v.NetworkActivity);
                        //PrintError("kek4");
                        //PrintError(String.Format("{0} must have: {1}", v.Name, mustHave));
                        var modifier = s != "" && v.Modifiers.FirstOrDefault(x => x.Name == s) != null;
                        //if (r != null) PrintInfo(String.Format("r:{0}", r.IsInAbilityPhase));
                        //if (r2 != null) PrintInfo(String.Format("r2:{0} ", r2.Name));
                        if ((r != null && r.IsInAbilityPhase) || (r2 != null && r2.IsInAbilityPhase) ||
                            mustHave && modifier && act || !mustHave && act)
                        {
                            UsaSafeItems(v, enumerable, abilities);
                        }
                    }
                    if ((blink != null && blink.Cooldown > 11) || forcestaff != null && forcestaff.Cooldown > 18.6)
                    {
                        UseDisableStageOne(v, enumerable, abilities, true);
                    }
                    else if (_activated)
                    {
                        UseDisableStageOne(v, enumerable, abilities, true);
                    }
                    else if (Initiators.TryGetValue(v.ClassID, out spellString))
                    {
                        var initSpell = v.FindSpell(spellString);
                        if (initSpell != null && initSpell.Cooldown != 0)
                        {
                            UseDisableStageOne(v, enumerable, abilities, true);
                        }
                    }
                }
                catch (Exception)
                {
                    // ignored
                }
            }
        }