Exemple #1
0
        public override void AI()
        {
            //Basically the code for a spirit heal
            int     netTarget = (int)projectile.ai[0];
            int     target    = (int)projectile.ai[0];
            int     healPower = (int)projectile.ai[1];
            float   num605    = 4f;
            Vector2 center    = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
            float   dX        = Main.npc[target].Center.X - center.X;
            float   dY        = Main.npc[target].Center.Y - center.Y;
            float   distance  = (float)Math.Sqrt((double)(dX * dX + dY * dY));

            if (distance < 50f && projectile.position.X < Main.npc[target].position.X + (float)Main.npc[target].width && projectile.position.X + (float)projectile.width > Main.npc[target].position.X && projectile.position.Y <Main.npc[target].position.Y + (float)Main.npc[target].height && projectile.position.Y + (float)projectile.height> Main.npc[target].position.Y)
            {
                if (projectile.owner == Main.myPlayer)
                {
                    MNPC.healNPC(Main.npc[496], (int)healPower);
                    NetMessage.SendData(66, -1, -1, null, netTarget, (float)healPower, 0f, 0f, 0, 0, 0);
                }
                projectile.Kill();
            }
            distance = num605 / distance;
            dX      *= distance;
            dY      *= distance;
            projectile.velocity.X = (projectile.velocity.X * 15f + dX) / 16f;
            projectile.velocity.Y = (projectile.velocity.Y * 15f + dY) / 16f;

            for (int i = 0; i < 255; i++)
            {
                Player p = Main.player[i];
                //Find the rectangles or "hitboxes" of the npc and projectile
                Rectangle mb = new Rectangle((int)projectile.position.X + (int)projectile.velocity.X, (int)projectile.position.Y + (int)projectile.velocity.Y, projectile.width, projectile.height);
                Rectangle nb = new Rectangle((int)p.position.X, (int)p.position.Y, p.width, p.height);

                //If the two cross together
                if (mb.Intersects(nb) && p.active && projectile.owner == Main.myPlayer)
                {
                    MPlayer.healPlayer(p, (int)healPower);
                    NetMessage.SendData(66, -1, -1, null, p.whoAmI, (float)healPower, 0f, 0f, 0, 0, 0);
                    projectile.Kill();
                }
            }

            //Dust in the image of the spirit heal with a different dust value
            for (int num614 = 0; num614 < 5; num614++)
            {
                float num615 = projectile.velocity.X * 0.2f * (float)num614;
                float num616 = -(projectile.velocity.Y * 0.2f) * (float)num614;
                int   num617 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 59, 0f, 0f, 100, default(Color), 1.3f);
                Main.dust[num617].noGravity = true;
                Main.dust[num617].velocity *= 0f;
                Dust dust61 = Main.dust[num617];
                dust61.position.X = dust61.position.X - num615;
                Dust dust62 = Main.dust[num617];
                dust62.position.Y = dust62.position.Y - num616;
            }
        }
Exemple #2
0
        public override void AI()
        {
            bool exists   = false;
            int  Berramyr = 0;

            for (int i = 0; i < Main.npc.Length - 1; i++)
            {
                if (Main.npc[i].type == mod.NPCType("Berramyr"))
                {
                    Berramyr = i;
                    exists   = true;
                    break;
                }
            }

            if (Main.npc[Berramyr].life < 1 || !exists)
            {
                npc.life -= npc.life;
                npc.checkDead();
            }

            double deg  = (double)npc.ai[0];
            double rad  = deg * (Math.PI / 180);
            double dist = 150;

            if (!npc.dontTakeDamage)
            {
                if (npc.ai[0] % 120 == 0)
                {
                    MNPC.healNPC(Main.npc[Berramyr], 1000);
                }
                if (npc.ai[0] % 300 == 0 && Main.netMode != 1)
                {
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, 0, mod.ProjectileType("Berraheal"), 0, 0f, Main.myPlayer, Berramyr, 5000);
                }
            }

            npc.position.X = Main.npc[Berramyr].Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2;
            npc.position.Y = Main.npc[Berramyr].Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2;

            if (npc.ai[2] == 1)
            {
                if (npc.ai[0] % 30 == 0)
                {
                    for (int i = 225; i <= 315; i += 15)
                    {
                        float shotAngle = (float)(i * (Math.PI / 180));
                        float speedY    = (float)Math.Sin(shotAngle) * 10f;
                        float speedX    = (float)Math.Cos(shotAngle) * 10f;
                        int   proj1     = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, speedX, -speedY, mod.ProjectileType("Berrabullet"), 10, 0f, Main.myPlayer, 0f, 0f);
                        Main.projectile[proj1].timeLeft = 9999;
                        Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 11);
                    }
                }
            }
            if (npc.ai[2] == 2)
            {
                MNPC.entrapment(npc, Berramyr, rad);
            }

            npc.ai[0]    += 1f;
            npc.netUpdate = true;
        }