Exemple #1
0
 public void CastFlash(Vector3 position)
 {
     var flash = Player.Spells.FirstOrDefault(a => a.SData.Name == "summonerflash");
     if (flash != null && position.IsValid() && flash.IsReady)
     {
         Player.CastSpell(flash.Slot, position);
     }
 }
        /// <summary>
        /// Launches a projectile from player to target
        /// </summary>
        public WorldObject LaunchProjectile(WorldObject weapon, WorldObject ammo, WorldObject target, Vector3 origin, Quaternion orientation, Vector3 velocity)
        {
            var player = this as Player;

            if (!velocity.IsValid())
            {
                if (player != null)
                {
                    player.SendWeenieError(WeenieError.YourAttackMisfired);
                }

                return(null);
            }

            var proj = WorldObjectFactory.CreateNewWorldObject(ammo.WeenieClassId);

            proj.ProjectileSource = this;
            proj.ProjectileTarget = target;

            proj.ProjectileLauncher = weapon;

            proj.Location          = new Position(Location);
            proj.Location.Pos      = origin;
            proj.Location.Rotation = orientation;

            proj.Velocity = velocity;

            SetProjectilePhysicsState(proj, target);

            var success = LandblockManager.AddObject(proj);

            if (!success || proj.PhysicsObj == null)
            {
                if (!proj.HitMsg && player != null)
                {
                    player.Session.Network.EnqueueSend(new GameMessageSystemChat("Your missile attack hit the environment.", ChatMessageType.Broadcast));
                }

                return(null);
            }

            var pkStatus = player?.PlayerKillerStatus ?? PlayerKillerStatus.Creature;

            proj.EnqueueBroadcast(new GameMessagePublicUpdatePropertyInt(proj, PropertyInt.PlayerKillerStatus, (int)pkStatus));
            proj.EnqueueBroadcast(new GameMessageScript(proj.Guid, PlayScript.Launch, 0f));

            // detonate point-blank projectiles immediately

            /*var radsum = target.PhysicsObj.GetRadius() + proj.PhysicsObj.GetRadius();
             * var dist = Vector3.Distance(origin, dest);
             * if (dist < radsum)
             * {
             *  Console.WriteLine($"Point blank");
             *  proj.OnCollideObject(target);
             * }*/

            return(proj);
        }
        private void GetCellLineIntersectionOctree(ref MyIntersectionResultLineTriangle?result, ref Line modelSpaceLine, ref float?minDistanceUntilNow, CellData cachedDataCell, IntersectionFlags flags)
        {
            m_overlapElementCache.Clear();
            if (cachedDataCell.Octree != null)
            {
                Vector3 packedStart, packedEnd;
                cachedDataCell.GetPackedPosition(ref modelSpaceLine.From, out packedStart);
                cachedDataCell.GetPackedPosition(ref modelSpaceLine.To, out packedEnd);
                var ray = new Ray(packedStart, packedEnd - packedStart);
                cachedDataCell.Octree.GetIntersectionWithLine(ref ray, m_overlapElementCache);
            }

            for (int j = 0; j < m_overlapElementCache.Count; j++)
            {
                var i = m_overlapElementCache[j];

                if (cachedDataCell.VoxelTriangles == null) //probably not calculated yet
                {
                    continue;
                }

                // this should never happen
                if (i >= cachedDataCell.VoxelTriangles.Length)
                {
                    Debug.Assert(i < cachedDataCell.VoxelTriangles.Length);
                    continue;
                }

                MyVoxelTriangle voxelTriangle = cachedDataCell.VoxelTriangles[i];

                MyTriangle_Vertexes triangleVertices;
                cachedDataCell.GetUnpackedPosition(voxelTriangle.VertexIndex0, out triangleVertices.Vertex0);
                cachedDataCell.GetUnpackedPosition(voxelTriangle.VertexIndex1, out triangleVertices.Vertex1);
                cachedDataCell.GetUnpackedPosition(voxelTriangle.VertexIndex2, out triangleVertices.Vertex2);

                Vector3 calculatedTriangleNormal = MyUtils.GetNormalVectorFromTriangle(ref triangleVertices);
                if (!calculatedTriangleNormal.IsValid())
                {
                    continue;
                }
                //We dont want backside intersections
                if (((int)(flags & IntersectionFlags.FLIPPED_TRIANGLES) == 0) &&
                    Vector3.Dot(modelSpaceLine.Direction, calculatedTriangleNormal) > 0)
                {
                    continue;
                }

                // AABB intersection test removed, AABB is tested inside BVH
                float?distance = MyUtils.GetLineTriangleIntersection(ref modelSpaceLine, ref triangleVertices);

                //  If intersection occured and if distance to intersection is closer to origin than any previous intersection
                if ((distance != null) && ((result == null) || (distance.Value < result.Value.Distance)))
                {
                    minDistanceUntilNow = distance.Value;
                    result = new MyIntersectionResultLineTriangle(ref triangleVertices, ref calculatedTriangleNormal, distance.Value);
                }
            }
        }
Exemple #4
0
        /// <summary>
        ///     Executes on the specified position.
        /// </summary>
        /// <param name="position">The position.</param>
        private static void Execute(Vector3 position)
        {
            if (!position.IsValid())
            {
                return;
            }

            GlobalVariables.CastManager.Queque.Enqueue(4, () => GlobalVariables.Spells[SpellSlot.Q].Cast(position));
        }
Exemple #5
0
        private List <Obj_AI_Hero> GetRTarget(Vector3 from = new Vector3())
        {
            var pos = from.IsValid() ? from : Player.ServerPosition;

            return
                (HeroManager.Enemies.Where(
                     i => i.IsValidTarget() && Prediction.GetPrediction(i, 0.25f).UnitPosition.Distance(pos) <= R.Range)
                 .ToList());
        }
Exemple #6
0
        public void CastFlash(Vector3 position)
        {
            var flash = Player.Spells.FirstOrDefault(a => a.SData.Name == "summonerflash");

            if (flash != null && position.IsValid() && flash.IsReady)
            {
                Player.CastSpell(flash.Slot, position);
            }
        }
Exemple #7
0
        private static void Game_OnGameUpdate(EventArgs args)
        {
            Ulti();
            if (config.Item("useeflash", true).GetValue <KeyBind>().Active&&
                player.Spellbook.CanUseSpell(player.GetSpellSlot("SummonerFlash")) == SpellState.Ready)
            {
                FlashCombo();
            }
            switch (orbwalker.ActiveMode)
            {
            case Orbwalking.OrbwalkingMode.Combo:
                Combo();
                break;

            case Orbwalking.OrbwalkingMode.Mixed:
                Harass();
                break;

            case Orbwalking.OrbwalkingMode.LaneClear:
                Clear();
                break;

            case Orbwalking.OrbwalkingMode.LastHit:
                break;

            default:
                break;
            }
            Jungle.CastSmite(config.Item("useSmite").GetValue <KeyBind>().Active);

            var bladeObj =
                ObjectManager.Get <Obj_AI_Base>()
                .Where(
                    o => (o.Name == "ShenSpiritUnit" || o.Name == "ShenArrowVfxHostMinion") && o.Team == player.Team)
                .OrderBy(o => o.Distance(bladeOnCast))
                .FirstOrDefault();

            if (bladeObj != null)
            {
                blade = bladeObj.Position;
            }
            if (W.IsReady() && blade.IsValid())
            {
                foreach (var ally in HeroManager.Allies.Where(a => a.Distance(blade) < bladeRadius))
                {
                    var data = Program.IncDamages.GetAllyData(ally.NetworkId);
                    if (config.Item("autowAgg", true).GetValue <Slider>().Value <= data.AADamageCount)
                    {
                        W.Cast();
                    }
                    if (data.AADamageTaken >= ally.Health * 0.2f && config.Item("autow", true).GetValue <bool>())
                    {
                        W.Cast();
                    }
                }
            }
        }
Exemple #8
0
 private static List <Obj_AI_Hero> GetRTarget(Vector3 from = new Vector3())
 {
     return
         (HeroManager.Enemies.Where(
              i =>
              i.IsValidTarget() &&
              (from.IsValid() ? from : Player.ServerPosition).Distance(
                  Prediction.GetPrediction(i, 0.25f).UnitPosition) < R.Range).ToList());
 }
Exemple #9
0
        protected override void OnDraw(EventArgs args)
        {
            base.OnDraw(args);

            if (DrawingsMenu.Item("streamingmode").GetValue <bool>())
            {
                return;
            }
            if (Player.Distance(_preV3) < 1000)
            {
                Drawing.DrawCircle(_preV3, 75, Color.Gold);
            }

            foreach (var hero in HeroManager.Enemies.Where(h => h.IsValidTarget() && h.Distance(Player) < 1400))
            {
                var WProcDMG  = (((hero.Health / Player.GetAutoAttackDamage(hero)) / 3) - 1) * W.GetDamage(hero);
                var AAsNeeded = 0;
                if (W.Instance.State != SpellState.NotLearned)
                {
                    AAsNeeded = (int)((hero.Health - WProcDMG) / Player.GetAutoAttackDamage(hero));
                }
                else
                {
                    AAsNeeded = (int)(hero.Health / Player.GetAutoAttackDamage(hero));
                }
                if (AAsNeeded <= 3)
                {
                    Drawing.DrawText(hero.HPBarPosition.X + 5, hero.HPBarPosition.Y - 30, Color.Gold,
                                     "AAs to kill: " + AAsNeeded);
                }
                else
                {
                    Drawing.DrawText(hero.HPBarPosition.X + 5, hero.HPBarPosition.Y - 30, Color.White,
                                     "AAs to kill: " + AAsNeeded);
                }
            }

            if (!ComboMenu.Item("DrawE").GetValue <bool>() || (Player.UnderTurret(true) && Orbwalker.ActiveMode != Orbwalking.OrbwalkingMode.Combo))
            {
                return;
            }
            if (!E.IsReady() || !_condemnEndPosSimplified.IsValid() || Player.CountEnemiesInRange(E.Range) == 0)
            {
                return;
            }
            if (_condemnEndPos.IsCollisionable())
            {
                Geometry.Util.DrawLineInWorld(Player.ServerPosition, _condemnEndPosSimplified, 2, Color.Gold);
                Drawing.DrawCircle(_condemnEndPos, 70, Color.Gold);
            }
            else
            {
                Geometry.Util.DrawLineInWorld(Player.ServerPosition, _condemnEndPosSimplified, 2, Color.White);
                Drawing.DrawCircle(_condemnEndPos, 70, Color.White);
            }
        }
Exemple #10
0
        private void Flee(Vector3 pos)
        {
            if (!GetValue <bool>("Flee", "Q") || !Q.IsReady())
            {
                return;
            }
            Obj_AI_Base obj     = null;
            var         jumpPos = Player.Distance(pos) > Q.Range ? Player.ServerPosition.Extend(pos, Q.Range) : pos;

            if (_wardPlacePos.IsValid())
            {
                obj =
                    ObjectManager.Get <Obj_AI_Minion>()
                    .FirstOrDefault(
                        i => i.IsValidTarget(Q.Range, false) && i.Distance(_wardPlacePos) < 200 && IsWard(i));
            }
            if (!_wardPlacePos.IsValid() || obj == null)
            {
                obj =
                    HeroManager.AllHeroes.Where(
                        i => !i.IsMe && i.IsValidTarget(Q.Range, false) && i.Distance(jumpPos) < 200)
                    .MinOrDefault(i => i.Distance(jumpPos)) ??
                    MinionManager.GetMinions(Q.Range, MinionTypes.All, MinionTeam.All)
                    .Where(i => i.Distance(jumpPos) < 200)
                    .MinOrDefault(i => i.Distance(jumpPos));
            }
            if (obj != null)
            {
                Q.CastOnUnit(obj, PacketCast);
            }
            else if (GetWardSlot != null)
            {
                var subPos = Player.Distance(pos) > GetWardRange
                    ? Player.ServerPosition.Extend(pos, GetWardRange - 30)
                    : pos;

                if (Player.Spellbook.CastSpell(GetWardSlot.SpellSlot, subPos))
                {
                    _wardPlacePos = subPos;
                    Utility.DelayAction.Add(500, () => _wardPlacePos = new Vector3());
                }
            }
        }
Exemple #11
0
        public static double GetAngle(Obj_AI_Base source, Vector3 target)
        {
            if (source == null || !target.IsValid())
            {
                return(0);
            }
            return(source.Direction.LSTo2D().LSPerpendicular().LSAngleBetween((target - source.Position).LSTo2D()));

            ;
        }
Exemple #12
0
 private static void Drawing_OnDraw(EventArgs args)
 {
     if (!Program.drawinsecLine)
         return;
     var target = TargetSelector.GetSelectedTarget();
     if (target.IsValidTarget() && !target.IsZombie)
     {
         Render.Circle.DrawCircle(target.Position, 100, Color.Yellow);
         if (InsecPoint.IsValid())
         {
             var point = target.Distance(InsecPoint) >= 400 ?
                 target.Position.Extend(InsecPoint, 400) : InsecPoint;
             Drawing.DrawLine(Drawing.WorldToScreen(target.Position)
                 , Drawing.WorldToScreen(point), 3, Color.Red);
         }
     }
     if (InsecPoint.IsValid())
         Render.Circle.DrawCircle(InsecPoint, 100, Color.Pink);
 }
Exemple #13
0
 public static float AngleBetween(Vector3 oldPosition, Vector3 newPosition)
 {
     if (oldPosition.IsValid() && newPosition.IsValid())
     {
         return
             ((oldPosition - ObjectManager.Player.Position).To2D()
              .AngleBetween((newPosition - ObjectManager.Player.Position).To2D()));
     }
     return(0f);
 }
Exemple #14
0
        private void Rmovement()
        {
            if (rActive && Game.CursorPos.CountEnemiesInRange(300) > 1)
            {
                AIHeroClient target = DrawHelper.GetBetterTarget(
                    E.Range, TargetSelector.DamageType.Physical, true, HeroManager.Enemies.Where(h => h.IsInvulnerable));
                if (target != null && target.CountEnemiesInRange(R.Range) > 1)
                {
                    if (System.Environment.TickCount - UltiCheck > 250 || UltiCheck == 0f)
                    {
                        var enemies =
                            HeroManager.Enemies.Where(e => e.IsValidTarget() && e.Distance(player) < 600)
                            .Select(e => Prediction.GetPrediction(e, 0.35f));
                        switch (config.Item("rType", true).GetValue <StringList>().SelectedIndex)
                        {
                        case 0:
                            point =
                                CombatHelper.PointsAroundTheTarget(player.Position, R.Range)
                                .Where(p => p.CountEnemiesInRange(R.Range + 100) > 0)
                                .OrderByDescending(
                                    p => enemies.Count(e => e.UnitPosition.Distance(p) <= R.Range))
                                .ThenBy(p => p.Distance(Game.CursorPos))
                                .FirstOrDefault();
                            break;

                        case 1:
                            point =
                                CombatHelper.PointsAroundTheTarget(target.Position, R.Range)
                                .Where(p => p.CountEnemiesInRange(R.Range + 100) > 0)
                                .OrderByDescending(
                                    p => enemies.Count(e => e.UnitPosition.Distance(p) <= R.Range))
                                .ThenBy(p => p.Distance(Game.CursorPos))
                                .FirstOrDefault();
                            break;

                        case 2:
                            point = Game.CursorPos;
                            break;
                        }
                    }

                    if (point.IsValid() && player.Distance(point) > 10 &&
                        point.CountEnemiesInRange(R.Range) > player.CountEnemiesInRange(R.Range))
                    {
                        orbwalker.SetMovement(false);
                        EloBuddy.Player.IssueOrder(GameObjectOrder.MoveTo, point);
                        UltiCheck = System.Environment.TickCount;
                    }
                }
            }
            else
            {
                orbwalker.SetMovement(true);
            }
        }
Exemple #15
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Vector3 pos = cam.ScreenPointToRay(Input.mousePosition).GroundPos();
         if (pos.IsValid())
         {
             robot.SetTargetPosition(pos);
         }
     }
 }
Exemple #16
0
 private static void SetSpellPosition(this Spell spell, Vector3 position)
 {
     if (position.IsValid())
     {
         spell.From           = position;
         spell.RangeCheckFrom = position;
         return;
     }
     spell.From           = new Vector3();
     spell.RangeCheckFrom = new Vector3();
 }
Exemple #17
0
        public static bool IsFacing(this Vector3 source, Vector3 target)
        {
            if (!source.IsValid() || !target.IsValid())
            {
                return(false);
            }

            const float angle = 90;

            return(source.To2D().AngleBetween((target - source).To2D()) < angle);
        }
Exemple #18
0
 private static void MoveTo(Vector3 pos)
 {
     if ((Pet.Path.LastOrDefault().Distance(pos) > 50 || !Pet.IsMoving) && pos.IsValid())
     {
         if (debug)
         {
             Console.WriteLine("move");
         }
         Pet.IssueOrder(GameObjectOrder.MovePet, pos);
     }
 }
Exemple #19
0
        public static double GetAngle(Obj_AI_Base source, Vector3 target)
        {
            if (source == null || !target.IsValid())
            {
                return(0);
            }
            return(Geometry.AngleBetween(
                       Geometry.Perpendicular(Geometry.To2D(source.Direction)), Geometry.To2D(target - source.Position)));

            ;
        }
        public override bool Use(Vector3 position)
        {
            if (position.IsValid())
            {
                throw new ArgumentNullException(nameof(position));
            }

            Log.Debug($"UseAbility {this.Instance.Name} @ {position}");
            this.Instance.UseAbility(position);
            return(true);
        }
Exemple #21
0
 public static bool IsFacing(Obj_AI_Base source, Vector3 target, float angle = 90)
 {
     if (source == null || !target.IsValid())
     {
         return(false);
     }
     return
         ((double)
          source.Direction.LSTo2D().LSPerpendicular().LSAngleBetween((target - source.Position).LSTo2D()) <
          angle);
 }
Exemple #22
0
 public static bool IsFacing(Obj_AI_Base source, Vector3 target, float angle = 90)
 {
     if (source == null || !target.IsValid())
     {
         return(false);
     }
     return
         ((double)
          Geometry.AngleBetween(
              Geometry.Perpendicular(Extensions.To2D(source.Direction)), Extensions.To2D(target - source.Position)) <
          angle);
 }
Exemple #23
0
        public Vector3 GetFirstWallPoint(Vector3 start, Vector3 end, float range)
        {
            if (end.IsValid() && start.Distance(end) <= range)
            {
                var newPoint = start.Extend(end, range);

                return(NavMesh.GetCollisionFlags(newPoint) == CollisionFlags.Wall || newPoint.IsWall()
                           ? newPoint
                           : Vector3.Zero);
            }
            return(Vector3.Zero);
        }
Exemple #24
0
        public static bool IsJumpable()
        {
            if (_rect == null)
            {
                return(false);
            }
            Vector3 position =
                (from x in JunglePos where !_rect.IsOutside(x.To2D()) || x.Distance(Game.CursorPos) < 200 select x)
                .FirstOrDefault();

            return((position.IsValid()) && CheckHandler._spells[SpellSlot.Q].IsReady());
        }
Exemple #25
0
        public override void AccumulateCorrection(ref Vector3 correction, ref float weight)
        {
            if (Parent.Speed < 0.01f)
            {
                return;
            }

            var characterBotEntity = Parent.BotEntity as MyCharacter; // remove me pls

            if (characterBotEntity == null)
            {
                return;
            }

            var          position        = Parent.PositionAndOrientation.Translation;
            BoundingBoxD box             = new BoundingBoxD(position - Vector3D.One * 3, position + Vector3D.One * 3);
            Vector3D     currentMovement = Parent.ForwardVector;

            var entities = MyEntities.GetEntitiesInAABB(ref box);

            foreach (var entity in entities)
            {
                var character = entity as MyCharacter;
                if (character == null || character == characterBotEntity)
                {
                    continue;
                }
                if (character.ModelName == characterBotEntity.ModelName) // remove me pls
                {
                    continue;
                }

                Vector3D characterPos = character.PositionComp.GetPosition();
                Vector3D dir          = characterPos - position;
                double   dist         = dir.Normalize();
                dist = MathHelper.Clamp(dist, 0, 6);
                var cos = Vector3D.Dot(dir, currentMovement);

                var opposite = -dir;
                if (cos > -0.807)
                {
                    correction += (6f - dist) * Weight * opposite;
                }

                if (!correction.IsValid())
                {
                    System.Diagnostics.Debugger.Break();
                }
            }
            entities.Clear();
            weight += Weight;
        }
Exemple #26
0
        private void Harass()
        {
            Obj_AI_Hero target = TargetSelector.GetTarget(E.Range, TargetSelector.DamageType.Physical);

            if (target == null)
            {
                return;
            }
            if (config.Item("eqweb").GetValue <bool>() && Q.IsReady() && E.IsReady() && lastE.Equals(0) && fury && !rene)
            {
                if (config.Item("donteqwebtower").GetValue <bool>() &&
                    player.Position.Extend(target.Position, E.Range).UnderTurret(true))
                {
                    return;
                }
                var closeGapTarget =
                    ObjectManager.Get <Obj_AI_Minion>()
                    .Where(
                        i =>
                        i.IsEnemy && player.Distance(i) < E.Range && !i.IsDead &&
                        i.Distance(target.ServerPosition) < Q.Range - 40)
                    .OrderByDescending(i => Environment.Minion.countMinionsInrange(i.Position, Q.Range))
                    .FirstOrDefault();
                if (closeGapTarget != null)
                {
                    lastEpos = player.ServerPosition;
                    Utility.DelayAction.Add(4100, () => lastEpos = new Vector3());
                    E.Cast(closeGapTarget.Position, config.Item("packets").GetValue <bool>());
                    lastE = System.Environment.TickCount;
                    return;
                }
                else
                {
                    lastEpos = player.ServerPosition;
                    Utility.DelayAction.Add(4100, () => lastEpos = new Vector3());
                    E.Cast(target.Position, config.Item("packets").GetValue <bool>());
                    lastE = System.Environment.TickCount;
                    return;
                }
            }
            if (config.Item("useqH").GetValue <bool>() && Q.CanCast(target))
            {
                Q.Cast(config.Item("packets").GetValue <bool>());
            }
            if (config.Item("eqweb").GetValue <bool>() && !lastE.Equals(0) && rene && !Q.IsReady() && !renw)
            {
                if (lastEpos.IsValid())
                {
                    E.Cast(player.Position.Extend(lastEpos, 350f), config.Item("packets").GetValue <bool>());
                }
            }
        }
Exemple #27
0
        private static void Game_OnGameUpdate(EventArgs args)
        {
            Ulti();
            if (getKeyBindItem(menuC, "useeflash") &&
                player.Spellbook.CanUseSpell(player.GetSpellSlot("SummonerFlash")) == SpellState.Ready)
            {
                FlashCombo();
            }

            if (Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.Combo))
            {
                Combo();
            }

            if (Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.Harass))
            {
                Harass();
            }

            if (Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.LaneClear) ||
                Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.JungleClear))
            {
                Clear();
            }

            var bladeObj =
                ObjectManager.Get <Obj_AI_Base>()
                .Where(
                    o => (o.Name == "ShenSpiritUnit" || o.Name == "ShenArrowVfxHostMinion") && o.Team == player.Team)
                .OrderBy(o => o.LSDistance(bladeOnCast))
                .FirstOrDefault();

            if (bladeObj != null)
            {
                blade = bladeObj.Position;
            }
            if (W.IsReady() && blade.IsValid())
            {
                foreach (var ally in HeroManager.Allies.Where(a => a.LSDistance(blade) < bladeRadius))
                {
                    var data = Program.IncDamages.GetAllyData(ally.NetworkId);
                    if (getSliderItem(menuU, "autowAgg") <= data.AADamageCount)
                    {
                        W.Cast();
                    }
                    if (data.AADamageTaken >= ally.Health * 0.2f && getCheckBoxItem(menuU, "autow"))
                    {
                        W.Cast();
                    }
                }
            }
        }
Exemple #28
0
 public static void applyImpulseNow(Rigidbody thisObject, Vector3 impulse, Vector3 worldPos, Matrix4x4 invWorldInertiaTensor)
 {
     if (thisObject.mass != 0f && 1f / thisObject.mass != 0f && impulse.IsValid() && impulse != Vector3.zero)
     {
         impulse              = impulse.normalized * Mathf.Clamp(impulse.magnitude, 0f, 6f);
         thisObject.velocity += impulse / thisObject.mass;
         Vector3 angularImpulse = Vector3.Cross(worldPos - thisObject.worldCenterOfMass, invWorldInertiaTensor * impulse);
         if (angularImpulse.magnitude < 4f)
         {
             thisObject.angularVelocity += angularImpulse;
         }
     }
 }
        private Vector3 GetDirection(Vector3 position, Vector3 sphereCenter)
        {
            Vector3 dist = position - sphereCenter;

            if (dist.IsValid() && MyUtils.HasValidLength(dist))
            {
                return(Vector3.Normalize(dist));
            }
            else
            {
                return(MyUtils.GetRandomVector3Normalized());
            }
        }
Exemple #30
0
 private int GetRangeDelay(Vector3 position, Vector3 lastPosition, int percent)
 {
     if (percent > 0 && position.IsValid() && lastPosition.IsValid())
     {
         var distance = position.Distance(lastPosition);
         if (Helpers.AngleBetween(lastPosition, position) > _random.Next(10, 16) && distance > 250)
         {
             var rangeDelay = (int)((distance * _random.Next(75, 86) / 100) / 100 * percent);
             return(Math.Min(_random.Next(1250, 1500), rangeDelay));
         }
     }
     return(0);
 }
Exemple #31
0
 public override void AccumulateCorrection(ref Vector3 correction, ref float weight)
 {
     if (base.Parent.Speed >= 0.01)
     {
         MatrixD    positionAndOrientation = base.Parent.PositionAndOrientation;
         Vector3D   translation            = positionAndOrientation.Translation;
         Quaternion identity = Quaternion.Identity;
         MyPhysics.GetPenetrationsShape((HkShape) new HkSphereShape(6f), ref translation, ref identity, this.m_trees, 9);
         foreach (HkBodyCollision collision in this.m_trees)
         {
             if (collision.Body == null)
             {
                 continue;
             }
             MyPhysicsBody userObject = collision.Body.UserObject as MyPhysicsBody;
             if (userObject != null)
             {
                 HkShape shape = collision.Body.GetShape();
                 if (shape.ShapeType == HkShapeType.StaticCompound)
                 {
                     int  num;
                     uint num2;
                     HkStaticCompoundShape shape2 = (HkStaticCompoundShape)shape;
                     shape2.DecomposeShapeKey(collision.ShapeKey, out num, out num2);
                     Vector3D vectord2  = shape2.GetInstanceTransform(num).Translation + userObject.GetWorldMatrix().Translation;
                     Vector3D direction = vectord2 - translation;
                     double   num3      = direction.Normalize();
                     direction   = Vector3D.Reject(base.Parent.ForwardVector, direction);
                     direction.Y = 0.0;
                     if (((direction.Z * direction.Z) + (direction.X * direction.X)) < 0.1)
                     {
                         direction = translation - vectord2;
                         direction = Vector3D.Cross(Vector3D.Up, direction);
                         if (Vector3D.TransformNormal(direction, base.Parent.PositionAndOrientationInverted).X < 0.0)
                         {
                             direction = -direction;
                         }
                     }
                     direction.Normalize();
                     correction += ((6.0 - num3) * base.Weight) * direction;
                     if (!correction.IsValid())
                     {
                         Debugger.Break();
                     }
                 }
             }
         }
         this.m_trees.Clear();
         weight += base.Weight;
     }
 }
Exemple #32
0
        public static Vector3 GetFirstWallPoint(Vector3 start, Vector3 end, int step = 1)
        {
            if (start.IsValid() && end.IsValid())
            {
                var distance = start.LSDistance(end);
                for (var i = 0; i < distance; i = i + step)
                {
                    var newPoint = start.LSExtend(end, i);

                    if (NavMesh.GetCollisionFlags(newPoint) == CollisionFlags.Wall || newPoint.LSIsWall())
                    {
                        return newPoint;
                    }
                }
            }
            return Vector3.Zero;
        }
Exemple #33
0
        private static float GetWallWidth(Vector3 start, Vector3 direction, int maxWallWidth = 350, int step = 1)
        {
            var thickness = 0f;

            if (!start.IsValid() || !direction.IsValid())
            {
                return thickness;
            }

            for (var i = 0; i < maxWallWidth; i = i + step)
            {
                if (NavMesh.GetCollisionFlags(start.Extend(direction, i)) == CollisionFlags.Wall || start.Extend(direction, i).IsWall())
                {
                    thickness += step;
                }
            }
            return thickness;
        }
Exemple #34
0
       /// <summary>
       /// Gets the first wall point/node, w/e. 
       /// </summary>
       /// <param name="playerPosition"></param>
       /// <param name="endPosition"></param>
       /// <param name="step"></param>
       /// <returns></returns>
        public Vector3 FirstWallPoint(Vector3 playerPosition, Vector3 endPosition, int step = 1)
        {
            if (!playerPosition.IsValid() || !endPosition.IsValid())
            {
                return Vector3.Zero;
            }

            var distance = playerPosition.Distance(endPosition);

            for (var i = 0; i < distance; i = i + step)
            {
                var newPoint = playerPosition.Extend(endPosition, i);

                if (NavMesh.GetCollisionFlags(newPoint) == CollisionFlags.Wall || newPoint.IsWall())
                {
                    return newPoint;
                }
            }

            return Vector3.Zero;
        }
Exemple #35
0
        public static float GetWallWidth(Vector3 start, Vector3 direction, int maxWallWidth = 350, int step = 1)
        {
            var thickness = 0f;

            if (start.IsValid() && direction.IsValid())
            {
                for (var i = 0; i < maxWallWidth; i = i + step)
                {
                    if (NavMesh.GetCollisionFlags(start.Extend(direction, i)) == CollisionFlags.Wall
                        || start.Extend(direction, i).IsWall())
                    {
                        // Console.WriteLine("Thickness: " + thickness);
                        thickness += step;
                    }
                    else
                    {
                        return thickness;
                    }
                }
            }
            return thickness;
        }
Exemple #36
0
        /// <summary>
        ///     Returns a list of predicted minion positions.
        /// </summary>
        /// <param name="minions">
        ///     Given Minion List
        /// </param>
        /// <param name="delay">
        ///     Skill-shot Delay
        /// </param>
        /// <param name="width">
        ///     Skill-shot Width
        /// </param>
        /// <param name="speed">
        ///     Skill-shot Speed
        /// </param>
        /// <param name="from">
        ///     The From
        /// </param>
        /// <param name="range">
        ///     Skill-shot Range
        /// </param>
        /// <param name="collision">
        ///     Has Collision Flag
        /// </param>
        /// <param name="stype">
        ///     Skill-shot Type
        /// </param>
        /// <param name="rangeCheckFrom">
        ///     Range check from Vector3 source
        /// </param>
        /// <returns>
        ///     List of Points in <see cref="Vector2" /> type
        /// </returns>
        public static List<Vector2> GetMinionsPredictedPositions(
            List<Obj_AI_Minion> minions,
            float delay,
            float width,
            float speed,
            Vector3 from,
            float range,
            bool collision,
            SkillshotType stype,
            Vector3 rangeCheckFrom = default(Vector3))
        {
            from = from.IsValid() ? from : ObjectManager.Player.ServerPosition;

            return (from minion in minions
                    select
                        Movement.GetPrediction(
                            new PredictionInput
                                {
                                    Unit = minion, Delay = delay, Radius = width, Speed = speed, From = @from,
                                    Range = range, Collision = collision, Type = stype, RangeCheckFrom = rangeCheckFrom
                                })
                    into pos
                    where pos.Hitchance >= HitChance.High
                    select pos.UnitPosition.ToVector2()).ToList();
        }