public override bool UseItem(Player player)
        {
            if (SGAPocketDim.WhereAmI == typeof(Limborinth))
            {
                GraphFinder(Limborinth.MazeGraphPoints[0], (player.Center / 16).ToPoint16());
                return(true);
            }

            Point16 pos = new Point16((int)player.Center.X >> 4, (int)player.Center.Y >> 4);

            if (finder.startingPosition.X == 0 || Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift))
            {
                finder.startingPosition = pos;
                Main.NewText("Tile Position Set! " + finder.startingPosition.X + " | " + finder.startingPosition.Y);
                return(true);
            }
            finder.wallsWeight = 250;

            finder.AStarTiles(pos, 1);

            return(true);
        }
Exemplo n.º 2
0
        public override void AI()
        {
            if (astar == null)
            {
                astar = new AStarPathFinder();
                astar.recursionLimit = 200;
                astar.wallsWeight    = 100;
                astar.seed           = npc.whoAmI;
            }
            npc.localAI[0] += 1;

            npc.spriteDirection = npc.velocity.X > 0 ? -1 : 1;
            //Main.NewText((int)astar.state + " " + npc.ai[1] + " " + npc.ai[0]+" "+ Path.Count);

            Player P = Main.player[npc.target];

            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest();
            }
            else
            {
                if (buffed == 0)
                {
                    bool bigtool = Main.player.Where(testby => testby.active && !testby.dead && testby.inventory.Where(testby2 => !testby2.IsAir && testby2.pick > 230).Count() > 0).Count() > 0;
                    buffed = bigtool || Dimensions.SpaceDim.postMoonLord ? 2 : 1;
                    if (buffed == 2)
                    {
                        npc.life           *= 5;
                        npc.lifeMax        *= 5;
                        npc.knockBackResist = 0f;
                        npc.value          *= 4;
                    }
                }

                if (npc.localAI[0] % 60 == 0)
                {
                    if (Collision.CanHitLine(P.MountedCenter, 1, 1, npc.Center, 1, 1))
                    {
                        Vector2 dist = P.Center - npc.Center;

                        if (dist.Length() < 200 + (buffed * 200))
                        {
                            Projectile.NewProjectile(npc.Center, dist, ModContent.ProjectileType <Items.Armors.Vibranium.VibraniumZapEffect>(), 0, 0);
                            SoundEffectInstance snd = Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 91);
                            P.AddBuff(BuffID.WitheredArmor, 60 * 5);
                            P.AddBuff(BuffID.WitheredWeapon, 60 * 5);
                            P.SGAPly().StackDebuff(ModLoader.GetMod("IDGLibrary").GetBuff("Radiation" + (buffed == 2 ? "Two" : "One")).Type, 60 * 6);
                        }
                    }
                }

                //Lets just assume netAlways can handle locations please?
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    //Time for the fancy AStar Nonsense!
                    if (astar.state != (int)PathState.Calculating)
                    {
                        npc.ai[1] = 0;
                        if (astar.state == (int)PathState.Finished || astar.state == (int)PathState.Failed)
                        {
                            //Gotta reverse it, so we don't start with the destination
                            Path = new List <PathNode>(astar.Path);
                            Path.Reverse();

                            astar.state = (int)PathState.Ready;
                        }
                        npc.ai[0] += (Path.Count < 2 && npc.ai[0] < 190) ? 3 : 1;
                        if (npc.ai[0] > 200)
                        {
                            astar.startingPosition = new Point16((int)npc.Center.X / 16, (int)npc.Center.Y / 16);
                            if (astar.AStarTiles(new Point16((int)P.Center.X / 16, (int)P.Center.Y / 16), 1))
                            {
                                npc.ai[0]     = Main.rand.Next(-50, 50);
                                npc.netUpdate = true;
                            }
                        }
                    }
                    else
                    {
                        npc.ai[1] += 1;

                        if (npc.ai[1] == 250)
                        {
                            //make portal thing
                            for (int i = 160; i < 320; i += 8)
                            {
                                Vector2 checkhere = P.MountedCenter + (Vector2.UnitX.RotatedBy(Main.rand.NextFloat(0f, MathHelper.TwoPi)) * i);
                                if (Collision.CanHitLine(P.MountedCenter, 1, 1, checkhere, 1, 1))
                                {
                                    npc.Center    = checkhere;
                                    npc.netUpdate = true;
                                }
                            }
                        }

                        if (npc.ai[1] > 300 && Path.Count < 5)
                        {
                            astar.state = (int)PathState.Ready;
                        }
                    }
                }
            }

            //if (astar.state != (int)PathState.Calculating)
            //{
            if (Path.Count > 0)
            {
                if (npc.localAI[0] % 1 == 0)
                {
                    Vector2 gothere = Path[0].location.ToVector2() * 16;

                    if (npc.Distance(gothere) > 16)
                    {
                        npc.velocity = Vector2.Normalize(gothere - npc.Center) * (buffed == 2 ? 16 : 4);
                    }
                    else
                    {
                        Path.RemoveAt(0);
                    }
                }
            }
            else
            {
            }
            //}

            npc.velocity *= (buffed == 2 ? 0.72f : 0.92f);
        }