예제 #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;
            }
        }
예제 #2
0
파일: Fokmyl.cs 프로젝트: Harrison-Jue/COFP
        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.ai[2] == 0)
            {
                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)
            {
                npc.position.Y = Main.npc[Berramyr].Center.Y - (npc.height / 2);
                npc.position.X = npc.ai[3];

                for (int i = 0; i < 255; i++)
                {
                    Player p = Main.player[i];
                    if (p.active && !p.dead)
                    {
                        if (p.position.X < npc.position.X)
                        {
                            p.position = p.oldPosition;
                        }
                    }
                }
            }
            if (npc.ai[2] == 2)
            {
                MNPC.entrapment(npc, Berramyr, rad);
            }

            npc.ai[0]    += 1f;
            npc.netUpdate = true;
        }
예제 #3
0
        /// <summary>
        /// Submodules offer extra functionality for e.g. user interaction, linking click handlers to widgets
        /// We don't want to copy their instance, because each has unique values, e.g. door state.
        /// </summary>
        /// <param name="bb"></param>
        /// <param name="o"></param>
        static void AddSubmodules(MBuildingBlock bb, MSceneObject o)
        {
            if (bb.SubModule == "MDoor")
            {
                MDoor door = new MDoor(o);
                o.Add(door);
            }

            if (bb.SubModule == "MLinker")
            {
                MLinker link = new MLinker();
                o.Add(link);
                MClickHandler mc = new MClickHandler();
                mc.DoubleClicked = MLinkerWidget.Mc_DoubleClick;
                mc.RightClicked  = MLinkerWidget.Mc_RightClick;
                o.Add(mc);
                o.Tag = "LINKER01|URL:";
            }

            if (bb.SubModule == "MTeleporter")
            {
                MClickHandler mc = new MClickHandler();
                mc.DoubleClicked = MTeleporterWidget.Mc_DoubleClick;
                mc.RightClicked  = MTeleporterWidget.Mc_RightClick;
                o.Add(mc);
                o.Tag = "TELEPORTER01|XYZ:";
            }


            if (bb.SubModule == "MPicture")
            {
                MClickHandler mc = new MClickHandler();
                mc.DoubleClicked = MPictureWidget.Mc_DoubleClick;
                mc.RightClicked  = MPictureWidget.Mc_RightClick;
                o.Add(mc);
                o.Tag = "PICTURE01|This Picture|Description";
            }

            if (bb.SubModule == "MStatus")
            {
                MClickHandler mc = new MClickHandler();
                mc.DoubleClicked = MStatusWidget.Mc_DoubleClick;
                mc.RightClicked  = MStatusWidget.Mc_RightClick;
                o.Add(mc);
                o.Tag = "STATUS01|This Status|Description";
            }

            if (bb.SubModule == "MNPC")
            {
                MNPC npc = new MNPC(o, "NPC");
                o.Add(npc);
            }
        }
예제 #4
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;

            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;
        }
예제 #5
0
        public override void AI()
        {
            Player owner = Main.player[Projectile.owner];

            if (first)
            {
                int  id             = NPC.NewNPC((int)Projectile.position.X, (int)Projectile.position.Y, ModContent.NPCType <NPC_Dog>());
                NPC  summonedNPC    = Main.npc[id];
                MNPC modSummonedNPC = summonedNPC.GetGlobalNPC <MNPC>();
                modSummonedNPC.barrel = Projectile;
                first = false;
            }



            //int DDustID = Dust.NewDust(Projectile.position - new Vector2(2f, 2f), Projectile.width + 4, Projectile.height + 4, 17, Projectile.velocity.X * 0.4f, Projectile.velocity.Y * 0.4f, 100, default(Color), 1.1f); //Spawns dust
            //Main.dust[DDustID].noGravity = true;
        }
예제 #6
0
        public override void AI()
        {
            bool exists          = false;
            bool hasFired        = false;
            int  Berramyr        = 0;
            int  friendProjCount = 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();
            }

            if (!npc.dontTakeDamage)
            {
                for (int i = 0; i < 255; i++)
                {
                    Player p = Main.player[i];
                    if (p.channel)
                    {
                        p.channel = false;
                    }
                }
                for (int i = 0; i < 1000; i++)
                {
                    Projectile p = Main.projectile[i];
                    if (p.friendly && p.active && !p.melee && !p.minion)
                    {
                        if (npc.ai[0] % 300 == 0 && !hasFired)
                        {
                            float shootToX = p.Center.X - npc.Center.X;
                            float shootToY = p.Center.Y - npc.Center.Y;
                            float distance = (float)Math.Sqrt((double)(shootToX * shootToX + shootToY * shootToY));
                            float speed    = 10f / distance;
                            shootToX *= speed;
                            shootToY *= speed;
                            Projectile.NewProjectile(npc.Center.X, npc.Center.Y, shootToX, shootToY, mod.ProjectileType("Lyndwave"), 0, 0, Main.myPlayer, 0f, 0f);
                            hasFired = true;
                        }
                        friendProjCount++;
                    }
                }
                if (friendProjCount > 5)
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        Projectile p = Main.projectile[i];
                        if (p.friendly && p.active && !p.melee && !p.minion)
                        {
                            p.aiStyle     = -2;
                            p.penetrate   = 1;
                            p.tileCollide = true;
                        }
                    }
                }
            }

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

            if (npc.ai[2] == 0)
            {
                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)
            {
                npc.position.Y = Main.npc[Berramyr].Center.Y - (npc.height / 2);
                npc.position.X = npc.ai[3];

                for (int i = 0; i < 255; i++)
                {
                    Player p = Main.player[i];
                    if (p.active && !p.dead)
                    {
                        if (p.position.X > npc.position.X)
                        {
                            p.position = p.oldPosition;
                        }
                    }
                }
            }
            if (npc.ai[2] == 2)
            {
                MNPC.entrapment(npc, Berramyr, rad);
            }

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