Пример #1
0
        private void Render_OnPresent()
        {
            foreach (var spell in SpellDetector.drawSpells.Values)
            {
                var spellPos = spell.currentSpellPosition;

                if (spell.heroID == myHero.NetworkId)
                {
                    if (spell.spellType == SpellType.Line)
                    {
                        if (Vector2.Distance(spellPos, myHero.ServerPosition.To2D()) <=
                            myHero.BoundingRadius + spell.radius &&
                            EvadeUtils.TickCount - spell.startTime > spell.info.spellDelay &&
                            Vector2.Distance(spell.startPos, myHero.ServerPosition.To2D()) < spell.info.range)
                        {
                            RenderObjects.Add(new RenderCircle(spellPos, 1000, Color.Red,
                                                               (int)spell.radius, 10));
                            DelayAction.Add(1, () => SpellDetector.DeleteSpell(spell.spellID));
                        }
                        else
                        {
                            Render.Circle(new Vector3(spellPos.X, spellPos.Y, myHero.Position.Z), (int)spell.radius,
                                          50, Color.White);
                        }
                    }
                    else if (spell.spellType == SpellType.Circular)
                    {
                        if (EvadeUtils.TickCount - spell.startTime >= spell.endTime - spell.startTime)
                        {
                            if (myHero.ServerPosition.To2D().InSkillShot(spell, myHero.BoundingRadius))
                            {
                                RenderObjects.Add(new RenderCircle(spellPos, 1000, Color.Red, (int)spell.radius, 5));
                                DelayAction.Add(1, () => SpellDetector.DeleteSpell(spell.spellID));
                            }
                        }
                    }
                    else if (spell.spellType == SpellType.Cone)
                    {
                        // SPELL TESTER
                        if (EvadeUtils.TickCount - spell.startTime >= spell.endTime - spell.startTime)
                        {
                            if (myHero.ServerPosition.To2D().InSkillShot(spell, myHero.BoundingRadius))
                            {
                                DelayAction.Add(1, () => SpellDetector.DeleteSpell(spell.spellID));
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        ///     Loads a single image texture into the skybox this will probably always result in visibale seams.
        /// </summary>
        /// <param name="program"></param>
        /// <returns></returns>
        public static ObjGroupSkyBox GetNewSkyBoxTypeT(ShaderProgram program, string aFilePath)
        {
            BoxIndex[] anBoxIndix = BoxIndex.GetTypeT();

            Dictionary <RenderObjects.BoxSides, Bitmap> tempBmpList =
//                RenderObjects.GetBoxTextures(@".\SkyBoxes\Above_The_Sea.jpg", 3, 4, anBoxIndix);
//                RenderObjects.GetBoxTextures(@".\SkyBoxes\2226.jpg", 3, 4, anBoxIndix);
//            RenderObjects.GetBoxTextures(@".\SkyBoxes\interstellar_large.jpg", 3, 4, anBoxIndix);
//            RenderObjects.GetBoxTextures(@".\SkyBoxes\grimmnight_large.jpg", 3, 4, anBoxIndix);
                RenderObjects.GetBoxTextures(aFilePath, 3, 4, anBoxIndix);

            ObjGroupSkyBox tempObjGroupSkyBox = GetTexturedBox3(program, tempBmpList);

            return(tempObjGroupSkyBox);
        }
Пример #3
0
 public static void RenderAllObjects()
 {
     for (int i = 0; i < RenderObjects.Count; i++)
     {
         if (RenderObjects[i] != null)
         {
             RenderObjects[i].Render();
             RenderObjects[i].ChainRender();
         }
         else
         {
             RenderObjects.RemoveAt(i);
             i--;
         }
     }
 }
Пример #4
0
        private void Game_OnCreateObj(GameObject sender)
        {
            var missile = sender as MissileClient;

            if (missile != null && missile.SpellCaster.IsMe)
            {
                if (lastSpellCastArgs.Process)
                {
                    //Draw.RenderObjects.Add(new Draw.RenderPosition(lastSpellCastServerPos, 1000, System.Drawing.Color.Red, 10));
                    RenderObjects.Add(new RenderCircle(missile.StartPosition.To2D(), 1000, Color.Red, 10));

                    var distance = lastSpellCastServerPos.Distance(missile.StartPosition.To2D());
                    var moveTime = 1000 * distance / myHero.MoveSpeed;
                    Console.WriteLine("Extra Delay: " + moveTime);
                }
            }
        }
Пример #5
0
        public Object3D AddObject(string fileName)
        {
            var      newObjectData = DataHandler.ReadFile(fileName);
            Object3D newObject     = null;

            void Add(object sender, FrameEventArgs e)
            {
                newObject = new Object3D(newObjectData);
                RenderObjects.Add(newObject);
                RenderFrame -= Add;
            }

            RenderFrame += Add;
            while (newObject == null)
            {
            }
            return(newObject);
        }
Пример #6
0
        private void Game_ProcessSpell(Obj_AI_Base hero, Obj_AI_BaseMissileClientDataEventArgs args)
        {
            if (!(hero is Obj_AI_Hero))
            {
                return;
            }

            if (TestMenu["(ShowProcessSpell)"].Enabled)
            {
                ConsolePrinter.Print(args.SpellData.Name + " CastTime: " + (hero.SpellBook.CastEndTime - Game.ClockTime));

                ConsolePrinter.Print("CastRadius: " + args.SpellData.CastRadius);
            }

            if (args.SpellData.Name == "YasuoQW")
            {
                RenderObjects.Add(new RenderCircle(args.Start.To2D(), 500));
                RenderObjects.Add(new RenderCircle(args.End.To2D(), 500));
            }

            _lastHeroSpellCastTime = Environment.TickCount;

            foreach (var entry in SpellDetector.Spells)
            {
                var spell = entry.Value;

                if (spell.Info.SpellName != args.SpellData.Name || spell.HeroId != hero.NetworkId)
                {
                    continue;
                }

                if (spell.Info.IsThreeWay == false && spell.Info.IsSpecial == false)
                {
                    ConsolePrinter.Print("Time diff: " + (Environment.TickCount - spell.StartTime));
                }
            }

            if (hero.IsMe)
            {
                _lastSpellCastTime = Environment.TickCount;
            }
        }
Пример #7
0
        private void Game_OnCastSpell(Obj_AI_Base sender, SpellBookCastSpellEventArgs e)
        {
            checkPing = false;

            if (!sender.IsMe)
            {
                return;
            }

            lastSpellCastArgs = e;


            if (myHero.HasPath && myHero.Path.Count() > 0)
            {
                lastSpellCastServerPos = EvadeUtils.GetGamePosition(myHero, Game.Ping);
                lastSpellCastEndPos    = myHero.Path.Last().To2D();
                checkPing = true;

                RenderObjects.Add(new RenderCircle(lastSpellCastServerPos, 1000, Color.Green, 10));
            }
        }
Пример #8
0
        private static void Game_OnCreateObj(GameObject sender)
        {
            var missile = sender as MissileClient;

            if (missile == null || !missile.SpellCaster.IsMe)
            {
                return;
            }

            if (!_lastSpellCastArgs.Process)
            {
                return;
            }

            RenderObjects.Add(new RenderCircle(missile.StartPosition.To2D(), 1000, Color.Red, 10));

            var distance = _lastSpellCastServerPos.Distance(missile.StartPosition.To2D());
            var moveTime = 1000 * distance / MyHero.MoveSpeed;

            Console.WriteLine("Extra Delay: " + moveTime);
        }
Пример #9
0
        private static void Game_OnCastSpell(Obj_AI_Base sender, SpellBookCastSpellEventArgs e)
        {
            _checkPing = false;

            if (!sender.IsMe)
            {
                return;
            }

            _lastSpellCastArgs = e;

            if (!MyHero.HasPath || !MyHero.Path.Any())
            {
                return;
            }

            _lastSpellCastServerPos = EvadeUtils.GetGamePosition(MyHero, Game.Ping);
            MyHero.Path.Last().To2D();
            _checkPing = true;

            RenderObjects.Add(new RenderCircle(_lastSpellCastServerPos, 1000, Color.Green, 10));
        }
Пример #10
0
        private void Game_OnCastSpell(Spellbook sender, SpellbookCastSpellEventArgs args)
        {
            var hero = sender.Owner;

            _checkPing = false;

            if (!hero.IsMe)
            {
                return;
            }

            _lastSpellCastArgs = args;


            if (MyHero.IsMoving && MyHero.Path.Count() > 0)
            {
                _lastSpellCastServerPos = EvadeUtils.GetGamePosition(MyHero, Game.Ping);
                _lastSpellCastEndPos    = MyHero.Path.Last().To2D();
                _checkPing = true;

                RenderObjects.Add(new RenderCircle(_lastSpellCastServerPos, 1000, Color.Green, 10));
            }
        }
Пример #11
0
    private void Awake()
    {
        if (Common.GetSelectedPlatform() == RuntimePlatform.Android)
        {
            this.gameObject.SetActive(false);
            return;
        }

        if (instance == null)
        {
            // Probably master or SDK
            instance        = this;
            rendererFeature = GetRendererFeature();
            Refresh();
        }
        else
        {
            // Copy parameter to the master
            instance.active                      = active;
            instance.skyColor                    = skyColor;
            instance.groundColor                 = groundColor;
            instance.scatteringIntensity         = scatteringIntensity;
            instance.skyExposure                 = skyExposure;
            instance.farPoint                    = farPoint;
            instance.startDistance               = startDistance;
            instance.endDistance                 = endDistance;
            instance.sunSize                     = sunSize;
            instance.sunBrightness               = sunBrightness;
            instance.atmosphereThickness         = atmosphereThickness;
            instance.maxScatteringValue          = maxScatteringValue;
            instance.horizonPoint                = horizonPoint;
            instance.horizonTransitionSmoothness = horizonTransitionSmoothness;
            instance.Refresh();
            this.enabled = false;
            Destroy(this);
        }
    }
Пример #12
0
 public void Refresh()
 {
     if (!rendererFeature)
     {
         rendererFeature = GetRendererFeature();
     }
     if (rendererFeature)
     {
         rendererFeature.SetActive(active);
     }
     atmosphereMaterial.SetFloat("_AtmoScatteringIntensity", scatteringIntensity);
     atmosphereMaterial.SetFloat("_AtmoScatterFarPoint", farPoint);
     atmosphereMaterial.SetFloat("_AtmoStartDist", startDistance);
     atmosphereMaterial.SetFloat("_AtmoEndDist", endDistance);
     atmosphereMaterial.SetFloat("_SunSize", sunSize);
     atmosphereMaterial.SetFloat("_SkyExposure", skyExposure);
     atmosphereMaterial.SetColor("_SkyTint", skyColor);
     atmosphereMaterial.SetColor("_GroundColor", groundColor);
     atmosphereMaterial.SetFloat("_SunBrightness", sunBrightness);
     atmosphereMaterial.SetFloat("_MaxScatteringValue", maxScatteringValue);
     atmosphereMaterial.SetFloat("_AtmosphereThickness", atmosphereThickness);
     atmosphereMaterial.SetFloat("_HorizonPoint", horizonPoint);
     atmosphereMaterial.SetFloat("_HorizonTransitionSmoothness", horizonTransitionSmoothness);
 }
Пример #13
0
        private static void Hero_OnNewPath(Obj_AI_Base hero, Obj_AI_BaseNewPathEventArgs args)
        {
            if (!ObjectCache.MenuCache.Cache["AutoSetPingOn"].Enabled)
            {
                return;
            }

            if (!hero.IsMe)
            {
                return;
            }

            var path = args.Path;

            if (path.Length <= 1 || args.IsDash)
            {
                return;
            }

            var movePos = path.Last().To2D();

            if (_checkPing && _lastIssueOrderArgs.ProcessEvent && _lastIssueOrderArgs.OrderType == OrderType.MoveTo && _lastIssueOrderArgs.Target.Position.To2D().Distance(movePos) < 3 &&
                MyHero.Path.Length == 1 && args.Path.Length == 2 && MyHero.HasPath)
            {
                RenderObjects.Add(new RenderLine(args.Path.First().To2D(), args.Path.Last().To2D(), 1000));
                RenderObjects.Add(new RenderLine(MyHero.Position.To2D(), MyHero.Path.Last().To2D(), 1000));

                var distanceTillEnd = MyHero.Path.Last().To2D().Distance(MyHero.Position.To2D());
                var moveTimeTillEnd = 1000 * distanceTillEnd / MyHero.MoveSpeed;

                if (moveTimeTillEnd < 500)
                {
                    return;
                }

                var myHeroPosition = new Vector3(MyHero.Position.X, MyHero.Position.Y, MyHero.Position.Z);

                var dir1 = (MyHero.Path.Last().To2D() - MyHero.Position.To2D()).Normalized();

                var ray1Startpos = new Vector3(myHeroPosition.X, myHeroPosition.Y, 0);
                var ray1Dir      = new Vector3(dir1.X, dir1.Y, 0);

                var dir2 = (args.Path.First().To2D() - args.Path.Last().To2D()).Normalized();

                var argsPathFirst = new Vector3(args.Path.First().X, args.Path.First().Y, args.Path.First().Z);

                var ray2Startpos = new Vector3(argsPathFirst.X, argsPathFirst.Y, 0);
                var ray2Dir      = new Vector3(dir2.X, dir2.Y, 0);

                var intersection = ray2Startpos.To2D().
                                   Intersection(ray2Startpos.To2D().ExtendDir(ray2Dir.To2D(), args.Path.Length), ray1Startpos.To2D(), ray1Startpos.To2D().ExtendDir(ray1Dir.To2D(), args.Path.Length));

                if (intersection.Intersects)
                {
                    var intersection3 = intersection.Point.To3D();

                    var x = intersection3.To2D().X;
                    var y = intersection3.To2D().Y;

                    var intersectionAt = new Vector2(x, y);

                    var projection = intersectionAt.ProjectOn(MyHero.Path.Last().To2D(), MyHero.Position.To2D());

                    if (projection.IsOnSegment && dir1.AngleBetween(dir2) > 20 && dir1.AngleBetween(dir2) < 160)
                    {
                        RenderObjects.Add(new RenderCircle(intersectionAt, 1000, Color.Red, 10));

                        var distance =
                            _lastMoveToServerPos.Distance(intersectionAt);
                        var moveTime = 1000 * distance / MyHero.MoveSpeed;

                        if (moveTime < 1000)
                        {
                            if (_numExtraDelayTime > 0)
                            {
                                PingList.Add(moveTime);
                            }
                            _numExtraDelayTime += 1;

                            if (_maxExtraDelayTime == 0)
                            {
                                _maxExtraDelayTime = ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value;
                            }

                            if (_numExtraDelayTime % 100 == 0)
                            {
                                PingList.Sort();

                                var percentile   = ObjectCache.MenuCache.Cache["AutoSetPercentile"].As <MenuSlider>().Value;
                                var percentIndex = (int)Math.Floor(PingList.Count * (percentile / 100f)) - 1;
                                _maxExtraDelayTime = Math.Max(PingList.ElementAt(percentIndex) - Game.Ping, 0);
                                ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value = (int)_maxExtraDelayTime; //(new MenuSlider((int)maxExtraDelayTime, 0, 200));

                                PingList.Clear();

                                Console.WriteLine("Max Extra Delay: " + _maxExtraDelayTime);
                            }

                            Console.WriteLine("Extra Delay: " + Math.Max(moveTime - Game.Ping, 0));
                        }
                    }
                }
            }

            _checkPing = false;
        }
Пример #14
0
        //private void GameObject_OnIntegerPropertyChange(GameObject obj, GameObjectIntegerPropertyChangeEventArgs args)
        //{
        //    if (obj.IsMe)
        //    {
        //        if (args.Property != "mExp" && args.Property != "mGold" && args.Property != "mGoldTotal")
        //        {
        //            ConsolePrinter.Print("Int" + args.Property + ": " + args.NewValue);
        //        }

        //    }
        //}

        private void Game_OnIssueOrder(Obj_AI_Base hero, Obj_AI_BaseIssueOrderEventArgs args)
        {
            if (!hero.IsMe)
            {
                return;
            }

            if (args.OrderType == OrderType.HoldPosition)
            {
                var path      = myHero.Path;
                var heroPoint = ObjectCache.myHeroCache.serverPos2D;


                if (path.Length > 0)
                {
                    var movePos = path[path.Length - 1].To2D();
                    var walkDir = (movePos - heroPoint).Normalized();

                    //circleRenderPos = EvadeHelper.GetRealHeroPos();
                    //heroPoint;// +walkDir * ObjectCache.myHeroCache.moveSpeed * (((float)ObjectCache.gamePing) / 1000);
                }
            }

            if (testMenu["(TestPath)"].As <MenuBool>().Enabled)
            {
                var tPath     = myHero.GetPath(args.Target.Position);
                var lastPoint = Vector2.Zero;

                foreach (var point in tPath)
                {
                    var point2D = point.To2D();
                    RenderObjects.Add(new RenderCircle(point2D, 500));
                    //Render.Circle.DrawCircle(new Vector3(point.X, point.Y, point.Z), ObjectCache.myHeroCache.boundingRadius, Color.Violet, 3);
                }
            }

            /*
             * if (args.OrderType == OrderType.MoveTo)
             * {
             *  if (testingCollision)
             *  {
             *      if (args.TargetPosition.To2D().Distance(testCollisionPos) < 3)
             *      {
             *          //var path = myHero.GetPath();
             *          //circleRenderPos
             *
             *          args.Process = false;
             *      }
             *  }
             * }*/

            if (args.OrderType == OrderType.MoveTo)
            {
                if (testMenu["(EvadeTesterPing)"].As <MenuBool>().Enabled)
                {
                    ConsolePrinter.Print("Sending Path ClickTime: " + (EvadeUtils.TickCount - lastRightMouseClickTime));
                }

                var heroPos = ObjectCache.myHeroCache.serverPos2D;
                var pos     = args.Target.Position.To2D();
                var speed   = ObjectCache.myHeroCache.moveSpeed;

                startWalkPos  = heroPos;
                startWalkTime = EvadeUtils.TickCount;

                foreach (var entry in SpellDetector.spells)
                {
                    var spell    = entry.Value;
                    var spellPos = spell.currentSpellPosition;
                    var walkDir  = (pos - heroPos).Normalized();


                    var spellTime = EvadeUtils.TickCount - spell.startTime - spell.info.spellDelay;
                    spellPos = spell.startPos + spell.direction * spell.info.projectileSpeed * (spellTime / 1000);
                    //ConsolePrinter.Print("aaaa" + spellTime);


                    var isCollision         = false;
                    var movingCollisionTime = MathUtils.GetCollisionTime(heroPos, spellPos, walkDir * (speed - 25),
                                                                         spell.direction * (spell.info.projectileSpeed - 200), ObjectCache.myHeroCache.boundingRadius,
                                                                         spell.radius, out isCollision);
                    if (isCollision)
                    {
                        if (true) //spellPos.Distance(spell.endPos) / spell.info.projectileSpeed > movingCollisionTime)
                        {
                            ConsolePrinter.Print("movingCollisionTime: " + movingCollisionTime);
                        }
                    }
                }
            }
        }
Пример #15
0
        private void Game_ProcessSpell(Obj_AI_Base hero, Obj_AI_BaseMissileClientDataEventArgs args)
        {
            if (!(hero is Obj_AI_Hero))
            {
                return;
            }


            if (testMenu["(ShowProcessSpell)"].As <MenuBool>().Enabled)
            {
                ConsolePrinter.Print(
                    args.SpellData.Name + " CastTime: " + (hero.SpellBook.CastEndTime - Game.ClockTime));

                ConsolePrinter.Print("CastRadius: " + args.SpellData.CastRadius);

                /*foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(args.SData))
                 * {
                 *  string name = descriptor.Name;
                 *  object value = descriptor.As(args.SData);
                 *  ConsolePrinter.Print("{0}={1}", name, value);
                 * }*/
            }

            if (args.SpellData.Name == "YasuoQW")
            {
                RenderObjects.Add(
                    new RenderCircle(args.Start.To2D(), 500));
                RenderObjects.Add(
                    new RenderCircle(args.End.To2D(), 500));
            }

            //ConsolePrinter.Print(EvadeUtils.TickCount - lastProcessPacketTime);
            //circleRenderPos = args.SpellData.ParticleStartOffset.To2D();

            /*Draw.RenderObjects.Add(
             *  new Draw.RenderPosition(args.Start.To2D(), Evade.GetTickCount + 500));
             * Draw.RenderObjects.Add(
             *  new Draw.RenderPosition(args.End.To2D(), Evade.GetTickCount + 500));*/

            /*float testTime;
             *
             *
             * testTime = Evade.GetTickCount;
             * for (int i = 0; i < 100000; i++)
             * {
             *  var testVar = ObjectCache.myHeroCache.boundingRadius;
             * }
             * ConsolePrinter.Print("Test time1: " + (Evade.GetTickCount - testTime));
             *
             * testTime = Evade.GetTickCount;
             * var cacheVar = ObjectCache.myHeroCache.boundingRadius;
             * for (int i = 0; i < 100000; i++)
             * {
             *  var testVar = cacheVar;
             * }
             * ConsolePrinter.Print("Test time1: " + (Evade.GetTickCount - testTime));*/

            // ConsolePrinter.Print("NetworkID: " + args.MissileNetworkId);

            lastHeroSpellCastTime = EvadeUtils.TickCount;

            foreach (var entry in SpellDetector.spells)
            {
                var spell = entry.Value;

                if (spell.info.spellName == args.SpellData.Name &&
                    spell.heroID == hero.NetworkId)
                {
                    if (spell.info.isThreeWay == false && spell.info.isSpecial == false)
                    {
                        ConsolePrinter.Print("Time diff: " + (EvadeUtils.TickCount - spell.startTime));
                    }
                }
            }

            if (hero.IsMe)
            {
                lastSpellCastTime = EvadeUtils.TickCount;
            }
        }
Пример #16
0
        private void SpellMissile_OnCreate(GameObject obj)
        {
            /*if (sender.Name.ToLower().Contains("minion")
            || sender.Name.ToLower().Contains("turret")
            || sender.Type == GameObjectType.obj_GeneralParticleEmitter)
            || {
            ||  return;
            || }
            ||
            || if (sender.IsValid<MissileClient>())
            || {
            ||  var tMissile = sender as MissileClient;
            ||  if (tMissile.SpellCaster.Type != GameObjectType.obj_AI_Hero)
            ||  {
            ||      return;
            ||  }
            || }
            ||
            || ConsolePrinter.Print(sender.Type + " : " + sender.Name);*/

            if (obj.IsValid && obj.Type == GameObjectType.MissileClient)
            {
                var mis = (MissileClient)obj;

                if (mis.SpellCaster is Obj_AI_Hero && mis.SpellData.ConsideredAsAutoAttack)
                {
                    ConsolePrinter.Print("[" + mis.SpellData.Name + "]: Missile Speed " + mis.SpellData.MissileSpeed);
                    ConsolePrinter.Print("[" + mis.SpellData.Name + "]: LineWidth " + mis.SpellData.LineWidth);
                    ConsolePrinter.Print("[" + mis.SpellData.Name + "]: Range " + mis.SpellData.CastRange);
                    ConsolePrinter.Print("[" + mis.SpellData.Name + "]: Accel " + mis.SpellData.MissileAccel);
                }
            }


            //ConsolePrinter.Print(obj.Name + ": " + obj.Type);

            if (!obj.IsValid || obj.Type != GameObjectType.MissileClient)
            {
                return;
            }

            if (testMenu["ShowMissileInfo"].As <MenuBool>().Value == false)
            {
                return;
            }


            var missile = (MissileClient)obj;

            if (!(missile.SpellCaster is Obj_AI_Hero))
            {
                return;
            }

            var testMissileSpeedStartTime = EvadeUtils.TickCount;
            var testMissileSpeedStartPos  = missile.Position.To2D();

            DelayAction.Add(250, () =>
            {
                if (missile != null && missile.IsValid && !missile.IsDead)
                {
                    testMissileSpeedStartTime = EvadeUtils.TickCount;
                    testMissileSpeedStartPos  = missile.Position.To2D();
                }
            });

            testMissile          = missile;
            testMissileStartTime = EvadeUtils.TickCount;

            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Est.CastTime: " +
                                 (EvadeUtils.TickCount - lastHeroSpellCastTime));
            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Missile Name " + missile.SpellData.Name);
            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Missile Speed " + missile.SpellData.MissileSpeed);
            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Accel " + missile.SpellData.MissileAccel);
            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Max Speed " + missile.SpellData.MissileMaxSpeed);
            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: LineWidth " + missile.SpellData.LineWidth);
            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Range " + missile.SpellData.CastRange);
            //ConsolePrinter.Print("Angle " + missile.SpellData.CastConeAngle);

            /*ConsolePrinter.Print("Offset: " + missile.SpellData.ParticleStartOffset);
             * ConsolePrinter.Print("Missile Speed " + missile.SpellData.MissileSpeed);
             * ConsolePrinter.Print("LineWidth " + missile.SpellData.LineWidth);
             * circleRenderPos = missile.SpellData.ParticleStartOffset.To2D();*/

            //ConsolePrinter.Print("Acquired: " + (EvadeUtils.TickCount - lastSpellCastTime));

            RenderObjects.Add(
                new RenderCircle(missile.StartPosition.To2D(), 500));
            RenderObjects.Add(
                new RenderCircle(missile.EndPosition.To2D(), 500));

            DelayAction.Add(750, () =>
            {
                if (missile != null && missile.IsValid && !missile.IsDead)
                {
                    var dist = missile.Position.To2D().Distance(testMissileSpeedStartPos);
                    ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Est.Missile speed: " +
                                         1000 * (dist / (EvadeUtils.TickCount - testMissileSpeedStartTime)));
                }
            });

            SpellData spellData;

            if (missile.SpellCaster != null && missile.SpellCaster.Team != myHero.Team &&
                missile.SpellData.Name != null &&
                SpellDetector.onMissileSpells.TryGetValue(missile.SpellData.Name, out spellData) &&
                missile.StartPosition != null && missile.EndPosition != null)
            {
                if (missile.StartPosition.Distance(myHero.Position) < spellData.range + 1000)
                {
                    var hero = missile.SpellCaster;

                    if (hero.IsVisible)
                    {
                        foreach (var entry in SpellDetector.spells)
                        {
                            var spell = entry.Value;

                            if (spell.info.missileName == missile.SpellData.Name &&
                                spell.heroID == missile.SpellCaster.NetworkId)
                            {
                                if (spell.info.isThreeWay == false && spell.info.isSpecial == false)
                                {
                                    ConsolePrinter.Print("Acquired: " + (EvadeUtils.TickCount - spell.startTime));
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #17
0
        void DrawLight(int idx, RenderObjects renderObjects, PointLight light, Matrix4 m, Matrix4 projectionMatrix, Matrix4 invViewMatrix, Camera camera, float zNear)
        {
            using (RenderStateBinder binder = device.ChangeRenderState())
            {
                device.RenderState.DepthWrite = true;
                device.RenderState.DepthTest = true;
                device.RenderState.ColorWrite = false;
                device.RenderState.FrontFace = FrontFaceDirection.CCW;
                device.RenderState.PolygonOffset = true;
                device.RenderState.PolygonOffsetFactor = -1.0f;
                device.RenderState.PolygonOffsetUnits = -1.0f;
                device.ApplyRenderState();

                device.SetShader(generate_dp_shadowmap);

                Vector3[,] direction = new Vector3[6, 2]
                {
                    { -Vector3.UnitX, Vector3.UnitY },
                    { Vector3.UnitX, Vector3.UnitY },
                    { -Vector3.UnitY, -Vector3.UnitZ },
                    { Vector3.UnitY, Vector3.UnitZ },
                    { -Vector3.UnitZ, Vector3.UnitY },
                    { Vector3.UnitZ, Vector3.UnitY },
                };

                TextureTarget[] targets = new TextureTarget[6]
                {
                    TextureTarget.TextureCubeMapPositiveX,
                    TextureTarget.TextureCubeMapNegativeX,
                    TextureTarget.TextureCubeMapPositiveY,
                    TextureTarget.TextureCubeMapNegativeY,
                    TextureTarget.TextureCubeMapPositiveZ,
                    TextureTarget.TextureCubeMapNegativeZ,
                };

                device.SetMatrix(MatrixModeEnum.Projection, Matrix4.Perspective(90.0f, 1.0f, Light.zNear, light.Radius));
                device.SetFramebuffer(shadow_fb);

                for (int i = 0; i < 6; i++)
                {
                    shadow_fb.SetTextureCubeMap(FramebufferAttachment.DepthAttachment, targets[i], 0, shadow_texture_cube);
                    device.Clear(BufferMask.DepthBuffer);

                    Matrix4 lightViewMatrix = Matrix4.LookAt(light.Position, light.Position + direction[i, 0], direction[i, 1]);

                    renderObjects(lightViewMatrix);
                }

                //// front
                //shadow_fb.SetTexture2D(FramebufferAttachment.DepthAttachment, 0, shadow_texture[1]);
                //device.SetFramebuffer(shadow_fb);
                //device.Clear(BufferMask.DepthBuffer);

                //generate_dp_shadowmap.GetUniform("direction").Set(1.0f);

                //Vector3 pos = light.Position;// -new Vector3(0.0f, 0.0f, 0.02f);
                //Matrix4 lightViewMatrix = Matrix4.LookAt(pos, pos + Vector3.UnitZ, Vector3.UnitY);

                //renderObjects(lightViewMatrix);

                //// back
                //shadow_fb.SetTexture2D(FramebufferAttachment.DepthAttachment, 0, shadow_texture[2]);
                //device.Clear(BufferMask.DepthBuffer);

                //generate_dp_shadowmap.GetUniform("direction").Set(-1.0f);

                //pos = light.Position;// -new Vector3(0.0f, 0.0f, 0.02f);
                //lightViewMatrix = Matrix4.LookAt(pos, pos + Vector3.UnitZ, Vector3.UnitY);
                //renderObjects(lightViewMatrix);
            }

            device.SetFramebuffer(lighting_fb);
            device.SetMatrix(MatrixModeEnum.Projection, projectionMatrix);

            using (RenderStateBinder binder = device.ChangeRenderState())
            {
                device.SetShader(deferred_pointlight);
                deferred_pointlight.GetSampler("color_texture").Set(color_texture);
                deferred_pointlight.GetSampler("normal_texture").Set(normal_texture);
                deferred_pointlight.GetSampler("depth_texture").Set(depth_texture);
                //deferred_pointlight.GetSampler("shadowFront_texture").Set(shadow_texture[1]);
                //deferred_pointlight.GetSampler("shadowBack_texture").Set(shadow_texture[2]);
                deferred_pointlight.GetSampler("shadow_texture").Set(shadow_texture_cube);

                deferred_pointlight.GetUniform("buffer_range").Set(1.0f / device.Width, 1.0f / device.Height);

                deferred_pointlight.GetUniform("ndc_to_view").Set(m);

                device.SetVertexBuffer(point_light_VB, 0);
                device.SetIndexBuffer(point_light_IB);

                deferred_pointlight.GetUniform("shadow_matrix").Set(invViewMatrix);
                deferred_pointlight.GetUniform("light_params").Set(light.Ambient, light.Diffuse, light.Specular, light.Shininess);
                deferred_pointlight.GetUniform("light_position").Set(Vector3.TransformPosition(light.Position, camera.ViewMatrix));
                deferred_pointlight.GetUniform("light_positionW").Set(light.Position);
                deferred_pointlight.GetUniform("light_radius2").Set(light.Radius2);
                deferred_pointlight.GetUniform("light_color").Set(light.Color);
                deferred_pointlight.GetUniform("depth_param1").Set(light.DepthParam1);
                deferred_pointlight.GetUniform("depth_param2").Set(light.DepthParam2);

                device.SetMatrix(MatrixModeEnum.ModelView, light.WorldMatrix * camera.ViewMatrix);

                Vector3 p = camera.Position - light.Position;

                device.RenderState.DepthWrite = false;
                device.RenderState.Blend = true;
                device.RenderState.BlendingFuncDst = BlendingFactorDest.One;
                device.RenderState.BlendingFuncSrc = BlendingFactorSrc.One;

                if (p.Length < light.Radius + 2.0f * zNear)
                {
                    device.RenderState.FrontFace = FrontFaceDirection.CCW;
                    device.RenderState.DepthFunction = DepthFunction.GEqual;
                    device.RenderState.StencilTest = false;
                    device.ApplyRenderState();

                    device.DrawElements(BeginMode.TriangleStrip, 0, point_light_primitives);
                }
                else
                {
                    if (has_stencil)
                    {
                        device.RenderState.FrontFace = FrontFaceDirection.CW;
                        device.RenderState.ColorWrite = false;
                        device.RenderState.DepthFunction = DepthFunction.Less;
                        device.RenderState.StencilTest = true;
                        device.RenderState.StencilFunc = StencilFunction.Always;
                        device.RenderState.StencilFail = StencilOpEnum.Keep;
                        device.RenderState.StencilZFail = StencilOpEnum.Keep;
                        device.RenderState.StencilZPass = StencilOpEnum.Replace;
                        device.RenderState.StencilFuncReference = idx;
                        device.ApplyRenderState();

                        device.DrawElements(BeginMode.TriangleStrip, 0, point_light_primitives);

                        device.RenderState.FrontFace = FrontFaceDirection.CCW;
                        device.RenderState.ColorWrite = true;
                        device.RenderState.DepthFunction = DepthFunction.GEqual;
                        device.RenderState.StencilFunc = StencilFunction.Equal;
                        device.RenderState.StencilZPass = StencilOpEnum.Keep;
                        device.RenderState.StencilFuncReference = idx;
                        device.ApplyRenderState();

                        device.DrawElements(BeginMode.TriangleStrip, 0, point_light_primitives);
                    }
                    else
                    {
                        device.RenderState.FrontFace = FrontFaceDirection.CW;
                        device.RenderState.DepthFunction = DepthFunction.Less;
                        device.RenderState.StencilTest = false;
                        device.ApplyRenderState();

                        device.DrawElements(BeginMode.TriangleStrip, 0, point_light_primitives);
                    }
                }
            }
        }
Пример #18
0
 private void OnSpellStartChange(MenuComponent sender, ValueChangedArgs e)
 {
     SpellStartPosition = MyHero.ServerPosition;
     RenderObjects.Add(new RenderCircle(SpellStartPosition.To2D(), 1000, Color.Red, 100, 20));
 }
Пример #19
0
        public void DrawLights(RenderObjects renderObjects, List<Light> lights, Matrix4 projectionMatrix, float zNear, Camera camera)
        {
            if (lights.Count == 0)
            {
                return;
            }

            Matrix4 invProjectionMatrix = Matrix4.Invert(projectionMatrix);
            Matrix4 invViewMatrix = Matrix4.Invert(camera.ViewMatrix);

            Matrix4 m =
                    new Matrix4(
                        new Vector4(2.0f, 0.0f, 0.0f, 0.0f),
                        new Vector4(0.0f, 2.0f, 0.0f, 0.0f),
                        new Vector4(0.0f, 0.0f, 2.0f, 0.0f),
                        new Vector4(-1.0f, -1.0f, -1.0f, 1.0f))
                  * invProjectionMatrix;

            int idx = 0;
            foreach (Light light in lights)
            {
                idx++;

                if (light is SpotLight)
                {
                    DrawLight(idx, renderObjects, (SpotLight)light, m, projectionMatrix, invViewMatrix, camera, zNear);
                }
                else // light is PointLight
                {
                    DrawLight(idx, renderObjects, (PointLight)light, m, projectionMatrix, invViewMatrix, camera, zNear);
                }
            }
        }
Пример #20
0
        private void SpellMissile_OnCreate(GameObject obj)
        {
            if (obj.IsValid && obj.Type == GameObjectType.MissileClient)
            {
                var mis = (MissileClient)obj;

                if (mis.SpellCaster is Obj_AI_Hero && mis.SpellData.ConsideredAsAutoAttack)
                {
                    ConsolePrinter.Print("[" + mis.SpellData.Name + "]: Missile Speed " + mis.SpellData.MissileSpeed);
                    ConsolePrinter.Print("[" + mis.SpellData.Name + "]: LineWidth " + mis.SpellData.LineWidth);
                    ConsolePrinter.Print("[" + mis.SpellData.Name + "]: Range " + mis.SpellData.CastRange);
                    ConsolePrinter.Print("[" + mis.SpellData.Name + "]: Accel " + mis.SpellData.MissileAccel);
                }
            }

            if (!obj.IsValid || obj.Type != GameObjectType.MissileClient)
            {
                return;
            }

            if (!TestMenu["ShowMissileInfo"].Enabled)
            {
                return;
            }

            var missile = (MissileClient)obj;

            if (!(missile.SpellCaster is Obj_AI_Hero))
            {
                return;
            }

            var testMissileSpeedStartTime = Environment.TickCount;
            var testMissileSpeedStartPos  = missile.Position.To2D();

            DelayAction.Add(250,
                            () =>
            {
                if (!missile.IsValid || missile.IsDead)
                {
                    return;
                }

                testMissileSpeedStartTime = Environment.TickCount;
                testMissileSpeedStartPos  = missile.Position.To2D();
            });

            _testMissile          = missile;
            _testMissileStartTime = Environment.TickCount;

            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Est.CastTime: " + (Environment.TickCount - _lastHeroSpellCastTime));
            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Missile Name " + missile.SpellData.Name);
            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Missile Speed " + missile.SpellData.MissileSpeed);
            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Accel " + missile.SpellData.MissileAccel);
            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Max Speed " + missile.SpellData.MissileMaxSpeed);
            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: LineWidth " + missile.SpellData.LineWidth);
            ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Range " + missile.SpellData.CastRange);

            RenderObjects.Add(new RenderCircle(missile.StartPosition.To2D(), 500));
            RenderObjects.Add(new RenderCircle(missile.EndPosition.To2D(), 500));

            DelayAction.Add(750,
                            () =>
            {
                if (!missile.IsValid || missile.IsDead)
                {
                    return;
                }

                var dist = missile.Position.To2D().Distance(testMissileSpeedStartPos);
                ConsolePrinter.Print("[" + missile.SpellData.Name + "]: Est.Missile speed: " + 1000 * (dist / (Environment.TickCount - testMissileSpeedStartTime)));
            });

            if (missile.SpellCaster == null || missile.SpellCaster.Team == MyHero.Team || missile.SpellData.Name == null ||
                !SpellDetector.OnMissileSpells.TryGetValue(missile.SpellData.Name, out var spellData) || missile.StartPosition == null || missile.EndPosition == null)
            {
                return;
            }

            if (!(missile.StartPosition.Distance(MyHero.Position) < spellData.Range + 1000))
            {
                return;
            }

            var hero = missile.SpellCaster;

            if (!hero.IsVisible)
            {
                return;
            }

            foreach (var entry in SpellDetector.Spells)
            {
                var spell = entry.Value;

                if (spell.Info.MissileName != missile.SpellData.Name || spell.HeroId != missile.SpellCaster.NetworkId)
                {
                    continue;
                }

                if (spell.Info.IsThreeWay == false && spell.Info.IsSpecial == false)
                {
                    ConsolePrinter.Print("Acquired: " + (Environment.TickCount - spell.StartTime));
                }
            }
        }
Пример #21
0
        void DrawLight(int idx, RenderObjects renderObjects, SpotLight light, Matrix4 m, Matrix4 projectionMatrix, Matrix4 invViewMatrix, Camera camera, float zNear)
        {
            using (RenderStateBinder binder = device.ChangeRenderState())
            {
                device.RenderState.DepthWrite = true;
                device.RenderState.DepthTest = true;
                device.RenderState.ColorWrite = false;
                device.RenderState.FrontFace = FrontFaceDirection.CCW;
                device.RenderState.PolygonOffset = true;
                device.RenderState.PolygonOffsetFactor = 0.0f;
                device.RenderState.PolygonOffsetUnits = -1.0f;
                device.ApplyRenderState();

                shadow_fb.SetTexture2D(FramebufferAttachment.DepthAttachment, 0, shadow_texture);
                device.SetFramebuffer(shadow_fb);

                device.Clear(BufferMask.DepthBuffer);

                device.SetShader(generate_shadowmap);

                device.SetMatrix(MatrixModeEnum.Projection, light.ProjectionMatrix);
                renderObjects(light.ViewMatrix);
            }

            device.SetFramebuffer(lighting_fb);
            device.SetMatrix(MatrixModeEnum.Projection, projectionMatrix);

            using (RenderStateBinder binder = device.ChangeRenderState())
            {
                device.SetShader(deferred_spotlight);
                deferred_spotlight.GetSampler("color_texture").Set(color_texture);
                deferred_spotlight.GetSampler("normal_texture").Set(normal_texture);
                deferred_spotlight.GetSampler("depth_texture").Set(depth_texture);
                deferred_spotlight.GetSampler("shadow_texture").Set(shadow_texture);

                deferred_spotlight.GetUniform("buffer_range").Set(1.0f / device.Width, 1.0f / device.Height);
                deferred_spotlight.GetUniform("ndc_to_view").Set(m);

                deferred_spotlight.GetUniform("shadow_matrix").Set(invViewMatrix * light.ShadowMatrix);
                deferred_spotlight.GetUniform("light_params").Set(light.Ambient, light.Diffuse, light.Specular, light.Shininess);
                deferred_spotlight.GetUniform("light_params2").Set(light.Length2, light.AngleParam1, light.AngleParam2, light.Exponent);
                deferred_spotlight.GetUniform("light_position").Set(Vector3.TransformPosition(light.Position, camera.ViewMatrix));
                deferred_spotlight.GetUniform("light_direction").Set(Vector3.TransformVector(light.Direction, camera.ViewMatrix));
                deferred_spotlight.GetUniform("light_color").Set(light.Color);

                device.SetVertexBuffer(spot_light_VB, 0);
                device.SetIndexBuffer(spot_light_IB);

                device.SetMatrix(MatrixModeEnum.ModelView, light.WorldMatrix * camera.ViewMatrix);

                bool inside = false;
                Vector3 p = (camera.Position + camera.ZAxis * zNear) - light.Position;
                float dot = Vector3.Dot(p, light.Direction);
                if (dot > 0.0f || dot < light.Length)
                {
                    float cosBeta = dot / p.Length;
                    if (cosBeta > Degrees.Cos(light.Angle + 5))
                    {
                        inside = true;
                    }
                }

                device.RenderState.DepthWrite = false;
                device.RenderState.Blend = true;
                device.RenderState.BlendingFuncDst = BlendingFactorDest.One;
                device.RenderState.BlendingFuncSrc = BlendingFactorSrc.One;

                if (inside)
                {
                    device.RenderState.FrontFace = FrontFaceDirection.CCW;
                    device.RenderState.DepthFunction = DepthFunction.GEqual;
                    device.RenderState.StencilTest = false;
                    device.ApplyRenderState();

                    device.DrawElements(BeginMode.TriangleStrip, 0, spot_light_primitives);
                }
                else
                {
                    if (has_stencil)
                    {
                        device.RenderState.FrontFace = FrontFaceDirection.CW;
                        device.RenderState.ColorWrite = false;
                        device.RenderState.DepthFunction = DepthFunction.Less;
                        device.RenderState.StencilTest = true;
                        device.RenderState.StencilFunc = StencilFunction.Always;
                        device.RenderState.StencilFail = StencilOpEnum.Keep;
                        device.RenderState.StencilZFail = StencilOpEnum.Keep;
                        device.RenderState.StencilZPass = StencilOpEnum.Replace;
                        device.RenderState.StencilFuncReference = idx;
                        device.ApplyRenderState();

                        device.DrawElements(BeginMode.TriangleStrip, 0, spot_light_primitives);

                        device.RenderState.FrontFace = FrontFaceDirection.CCW;
                        device.RenderState.ColorWrite = true;
                        device.RenderState.DepthFunction = DepthFunction.GEqual;
                        device.RenderState.StencilFunc = StencilFunction.Equal;
                        device.RenderState.StencilZPass = StencilOpEnum.Keep;
                        device.RenderState.StencilFuncReference = idx;
                        device.ApplyRenderState();

                        device.DrawElements(BeginMode.TriangleStrip, 0, spot_light_primitives);
                    }
                    else
                    {
                        device.RenderState.FrontFace = FrontFaceDirection.CW;
                        device.RenderState.DepthFunction = DepthFunction.Less;
                        device.RenderState.StencilTest = false;
                        device.ApplyRenderState();

                        device.DrawElements(BeginMode.TriangleStrip, 0, spot_light_primitives);
                    }
                }
            }
        }
Пример #22
0
        private void Hero_OnNewPath(Obj_AI_Base hero, Obj_AI_BaseNewPathEventArgs args)
        {
            if (ObjectCache.menuCache.cache["AutoSetPingOn"].As <MenuBool>().Value == false)
            {
                return;
            }

            if (!hero.IsMe)
            {
                return;
            }

            var path = args.Path;

            if (path.Length > 1 && !args.IsDash)
            {
                var movePos = path.Last().To2D();

                if (checkPing &&
                    lastIssueOrderArgs.ProcessEvent &&
                    lastIssueOrderArgs.OrderType == OrderType.MoveTo &&
                    lastIssueOrderArgs.Target.Position.To2D().Distance(movePos) < 3 &&
                    myHero.Path.Count() == 1 &&
                    args.Path.Count() == 2 &&
                    myHero.HasPath)
                {
                    //Draw.RenderObjects.Add(new Draw.RenderPosition(myHero.Path.Last().To2D(), 1000));

                    RenderObjects.Add(new RenderLine(args.Path.First().To2D(), args.Path.Last().To2D(), 1000));
                    RenderObjects.Add(new RenderLine(myHero.Position.To2D(), myHero.Path.Last().To2D(), 1000));

                    //Draw.RenderObjects.Add(new Draw.RenderCircle(lastMoveToServerPos, 1000, System.Drawing.Color.Red, 10));

                    var distanceTillEnd = myHero.Path.Last().To2D().Distance(myHero.Position.To2D());
                    var moveTimeTillEnd = 1000 * distanceTillEnd / myHero.MoveSpeed;

                    if (moveTimeTillEnd < 500)
                    {
                        return;
                    }

                    /*SharpDX.*/
                    var myHeroPosition = new /*SharpDX.*/
                                         Vector3(myHero.Position.X, myHero.Position.Y, myHero.Position.Z);

                    var dir1 = (myHero.Path.Last().To2D() - myHero.Position.To2D()).Normalized();

                    //SharpDX.Vector2 dir1sharpdx = new SharpDX.Vector2(myHero.Position.X, myHero.Position.Y);

                    //var ray1 = new Ray(myHeroPosition.SetZ(0), new SharpDX.Vector3(dir1.X, dir1.Y, 0));
                    var ray1startpos = new Vector3(myHeroPosition.X, myHeroPosition.Y, 0);
                    var ray1dir      = new Vector3(dir1.X, dir1.Y, 0);
                    //Vector3 ray1 = ray1startpos.ExtendDir(ray1dir, args.Path.Length);

                    var dir2 = (args.Path.First().To2D() - args.Path.Last().To2D()).Normalized();
                    //var pos2 = new Vector3(args.Path.First().X, args.Path.First().Y, 0);

                    /*SharpDX.*/
                    var argsPathFirst = new /*SharpDX.*/
                                        Vector3(args.Path.First().X, args.Path.First().Y, args.Path.First().Z);

                    //var ray2 = new Ray(argsPathFirst.SetZ(0), new SharpDX.Vector3(dir2.X, dir2.Y, 0));
                    var ray2startpos = new Vector3(argsPathFirst.X, argsPathFirst.Y, 0);
                    var ray2dir      = new Vector3(dir2.X, dir2.Y, 0);

                    //Vector3 ray2 = ray2startpos.ExtendDir(ray2dir, args.Path.Length);

                    /*SharpDX.*/ //Vector3 intersection3;

                    var intersection = ray2startpos.To2D()
                                       .Intersection(ray2startpos.To2D().ExtendDir(ray2dir.To2D(), args.Path.Length),
                                                     ray1startpos.To2D(), ray1startpos.To2D().ExtendDir(ray1dir.To2D(), args.Path.Length));


                    if (intersection.Intersects)
                    {
                        var intersection3 = intersection.Point.To3D();

                        var x = intersection3.To2D().X;
                        var y = intersection3.To2D().Y;

                        var intersectionAT = new Vector2(x, y);

                        var projection = intersectionAT.ProjectOn(myHero.Path.Last().To2D(), myHero.Position.To2D());

                        if (projection.IsOnSegment && dir1.AngleBetween(dir2) > 20 && dir1.AngleBetween(dir2) < 160)
                        {
                            RenderObjects.Add(new RenderCircle(intersectionAT, 1000, Color.Red, 10, 5));

                            var distance = //args.Path.First().To2D().Distance(intersection);
                                           lastMoveToServerPos.Distance(intersectionAT);
                            var moveTime = 1000 * distance / myHero.MoveSpeed;

                            //Console.WriteLine("waa: " + distance);

                            if (moveTime < 1000)
                            {
                                if (numExtraDelayTime > 0)
                                {
                                    sumExtraDelayTime += moveTime;
                                    avgExtraDelayTime  = sumExtraDelayTime / numExtraDelayTime;

                                    pingList.Add(moveTime);
                                }
                                numExtraDelayTime += 1;

                                if (maxExtraDelayTime == 0)
                                {
                                    maxExtraDelayTime = ObjectCache.menuCache.cache["ExtraPingBuffer"].As <MenuSlider>()
                                                        .Value;
                                }

                                if (numExtraDelayTime % 100 == 0)
                                {
                                    pingList.Sort();

                                    var percentile = ObjectCache.menuCache.cache["AutoSetPercentile"].As <MenuSlider>()
                                                     .Value;
                                    var percentIndex = (int)Math.Floor(pingList.Count() * (percentile / 100f)) - 1;
                                    maxExtraDelayTime = Math.Max(pingList.ElementAt(percentIndex) - Game.Ping, 0);
                                    ObjectCache.menuCache.cache["ExtraPingBuffer"].As <MenuSlider>().Value =
                                        (int)maxExtraDelayTime;  //(new MenuSlider((int)maxExtraDelayTime, 0, 200));

                                    pingList.Clear();

                                    Console.WriteLine("Max Extra Delay: " + maxExtraDelayTime);
                                }

                                Console.WriteLine("Extra Delay: " + Math.Max(moveTime - Game.Ping, 0));
                            }
                        }
                    }

                    //if (ray2.Intersects(ref ray1, out intersection3))
                    //{
                    //    //var intersection = intersection3.To2D();

                    //    float x = intersection3.To2D().X;
                    //    float y = intersection3.To2D().Y;

                    //    Vector2 intersectionAT = new Vector2(x, y);

                    //    var projection = intersectionAT.ProjectOn(myHero.Path.Last().To2D(), myHero.Position.To2D());

                    //    if (projection.IsOnSegment && dir1.AngleBetween(dir2) > 20 && dir1.AngleBetween(dir2) < 160)
                    //    {
                    //        Draw.RenderObjects.Add(new Draw.RenderCircle(intersectionAT, 1000, System.Drawing.Color.Red, 10, 5));

                    //        var distance = //args.Path.First().To2D().Distance(intersection);
                    //            lastMoveToServerPos.Distance(intersectionAT);
                    //        float moveTime = 1000 * distance / myHero.MoveSpeed;

                    //        //Console.WriteLine("waa: " + distance);

                    //        if (moveTime < 1000)
                    //        {
                    //            if (numExtraDelayTime > 0)
                    //            {
                    //                sumExtraDelayTime += moveTime;
                    //                avgExtraDelayTime = sumExtraDelayTime / numExtraDelayTime;

                    //                pingList.Add(moveTime);
                    //            }
                    //            numExtraDelayTime += 1;

                    //            if (maxExtraDelayTime == 0)
                    //            {
                    //                maxExtraDelayTime = ObjectCache.menuCache.cache["ExtraPingBuffer"].As<MenuSlider>().Value;
                    //            }

                    //            if (numExtraDelayTime % 100 == 0)
                    //            {
                    //                pingList.Sort();

                    //                var percentile = ObjectCache.menuCache.cache["AutoSetPercentile"].As<MenuSlider>().Value;
                    //                int percentIndex = (int)Math.Floor(pingList.Count() * (percentile / 100f)) - 1;
                    //                maxExtraDelayTime = Math.Max(pingList.ElementAt(percentIndex) - Game.Ping, 0);
                    //                ObjectCache.menuCache.cache["ExtraPingBuffer"].As<MenuSlider>().Value =
                    //                    (int)maxExtraDelayTime; //(new MenuSlider((int)maxExtraDelayTime, 0, 200));

                    //                pingList.Clear();

                    //                Console.WriteLine("Max Extra Delay: " + maxExtraDelayTime);
                    //            }

                    //            Console.WriteLine("Extra Delay: " + Math.Max(moveTime - Game.Ping, 0));
                    //        }
                    //    }
                    //}
                }

                checkPing = false;
            }
        }
Пример #23
0
        private void Hero_OnNewPath(Obj_AI_Base hero, GameObjectNewPathEventArgs args)
        {
            if (!Config.Properties.GetBool(ConfigValue.AutoSetPing))
            {
                return;
            }

            if (!hero.IsMe)
            {
                return;
            }

            var path = args.Path;

            if (path.Length > 1 && !args.IsDash)
            {
                var movePos = path.Last().To2D();

                if (_checkPing &&
                    _lastIssueOrderArgs.Process == true &&
                    _lastIssueOrderArgs.Order == GameObjectOrder.MoveTo &&
                    _lastIssueOrderArgs.TargetPosition.To2D().Distance(movePos) < 3 &&
                    MyHero.Path.Count() == 1 &&
                    args.Path.Count() == 2 &&
                    MyHero.IsMoving)
                {
                    //Draw.RenderObjects.Add(new Draw.RenderPosition(myHero.Path.Last().To2D(), 1000));

                    RenderObjects.Add(new RenderLine(args.Path.First().To2D(), args.Path.Last().To2D(), 1000));
                    RenderObjects.Add(new RenderLine(MyHero.Position.To2D(), MyHero.Path.Last().To2D(), 1000));

                    //Draw.RenderObjects.Add(new Draw.RenderCircle(lastMoveToServerPos, 1000, System.Drawing.Color.Red, 10));

                    var   distanceTillEnd = MyHero.Path.Last().To2D().Distance(MyHero.Position.To2D());
                    float moveTimeTillEnd = 1000 * distanceTillEnd / MyHero.MoveSpeed;

                    if (moveTimeTillEnd < 500)
                    {
                        return;
                    }

                    var dir1 = (MyHero.Path.Last().To2D() - MyHero.Position.To2D()).Normalized();
                    var ray1 = new Ray(MyHero.Position.SetZ(0), new Vector3(dir1.X, dir1.Y, 0));

                    var dir2 = (args.Path.First().To2D() - args.Path.Last().To2D()).Normalized();
                    var pos2 = new Vector3(args.Path.First().X, args.Path.First().Y, 0);
                    var ray2 = new Ray(args.Path.First().SetZ(0), new Vector3(dir2.X, dir2.Y, 0));

                    Vector3 intersection3;
                    if (ray2.Intersects(ref ray1, out intersection3))
                    {
                        var intersection = intersection3.To2D();

                        var projection = intersection.ProjectOn(MyHero.Path.Last().To2D(), MyHero.Position.To2D());

                        if (projection.IsOnSegment && dir1.AngleBetween(dir2) > 20 && dir1.AngleBetween(dir2) < 160)
                        {
                            RenderObjects.Add(new RenderCircle(intersection, 1000, Color.Red, 10));

                            var distance = //args.Path.First().To2D().Distance(intersection);
                                           _lastMoveToServerPos.Distance(intersection);
                            float moveTime = 1000 * distance / MyHero.MoveSpeed;

                            //ConsoleDebug.WriteLine("waa: " + distance);

                            if (moveTime < 1000)
                            {
                                if (_numExtraDelayTime > 0)
                                {
                                    _sumExtraDelayTime += moveTime;
                                    _avgExtraDelayTime  = _sumExtraDelayTime / _numExtraDelayTime;

                                    _pingList.Add(moveTime);
                                }
                                _numExtraDelayTime += 1;

                                if (_maxExtraDelayTime == 0)
                                {
                                    _maxExtraDelayTime = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer);
                                }

                                if (_numExtraDelayTime % 100 == 0)
                                {
                                    _pingList.Sort();

                                    var percentile   = ConfigValue.AutoSetPingPercentile.GetInt();
                                    int percentIndex = (int)Math.Floor(_pingList.Count() * (percentile / 100f)) - 1;
                                    _maxExtraDelayTime = Math.Max(_pingList.ElementAt(percentIndex) - Game.Ping, 0);
                                    _maxExtraDelayTime.SetTo(ConfigValue.ExtraPingBuffer);

                                    _pingList.Clear();

                                    ConsoleDebug.WriteLine("Max Extra Delay: " + _maxExtraDelayTime);
                                }

                                ConsoleDebug.WriteLine("Extra Delay: " + Math.Max(moveTime - Game.Ping, 0));
                            }
                        }
                    }
                }

                _checkPing = false;
            }
        }
Пример #24
0
        public void Render(RenderObjects renderObjects, Matrix4 projectionMatrix, Matrix4 viewMatrix)
        {
            device.SetFramebuffer(deferred_fb);

            using (RenderStateBinder binder = device.ChangeRenderState())
            {
                device.RenderState.DepthWrite = true;
                device.RenderState.DepthTest = true;
                device.ApplyRenderState();
                device.Clear(BufferMask.ColorBuffer | BufferMask.DepthBuffer | BufferMask.StencilBuffer);
            }

            device.SetShader(deferred_geometry);

            device.SetMatrix(MatrixModeEnum.Projection, projectionMatrix);

            renderObjects(viewMatrix);

            // TODO: add this as last pass
            device.SetFramebuffer(lighting_fb);

            using (RenderStateBinder binder = device.ChangeRenderState())
            {
                device.RenderState.DepthTest = false;
                device.RenderState.DepthWrite = false;
                device.ApplyRenderState();

                device.SetShader(deferred_ambient);
                deferred_ambient.GetSampler("color_texture").Set(color_texture);
                deferred_ambient.GetUniform("ambient_light").Set(0.7f); // TODO: full diffuse color for directional light

                device.SetVertexBuffer(unit_quad_VB, 0);
                device.DrawArrays(BeginMode.TriangleStrip, 0, 4);
            }
        }
Пример #25
0
 public void Insert(Model9 model, Entity e, MetaModel metaModel, string metaName)
 {
     RenderObjects.Add(new Common.Tuple <Model9, Entity, string>(model, e, metaName));
 }