Exemplo n.º 1
0
        public override void Kill(int timeLeft)
        {
            MMod.explosionEffect(projectile, 1f);

            Player target   = Main.player[(int)projectile.ai[0]];
            float  dX       = target.position.X + (float)target.width * 0.5f - projectile.Center.X;
            float  dY       = target.position.Y - projectile.Center.Y;
            float  distance = (float)System.Math.Sqrt((double)(dX * dX + dY * dY));

            if (distance < 50)
            {
                for (int i = 0; i < Main.npc.Length - 1; i++)
                {
                    NPC berramyr = Main.npc[i];
                    if (berramyr.type == mod.NPCType("Berramyr"))
                    {
                        target.Hurt(PlayerDeathReason.ByNPC(i), 10, projectile.direction);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void floatAround(Vector2 moveTo, Player p)
        {
            float fOne      = (float)Main.rand.Next(-100, 100);
            float fTwo      = (float)Main.rand.Next(-100, 100);
            float pX        = p.Center.X - npc.Center.X;
            float pY        = p.Center.Y - npc.Center.Y;
            float pDistance = (float)System.Math.Sqrt((double)(pX * pX + pY * pY));

            if (portCoolDown > 0)
            {
                portCoolDown--;
            }
            if (pDistance < 50 && portCoolDown == 0)
            {
                MMod.explosionEffect(npc, 4f);
                for (int i = 0; i < 255; i++)
                {
                    Player players         = Main.player[i];
                    float  dX              = players.Center.X - npc.Center.X;
                    float  dY              = players.Center.Y - npc.Center.Y;
                    float  playersDistance = (float)System.Math.Sqrt((double)dX * dX + dY * dY);
                    if (playersDistance < 50)
                    {
                        p.Hurt(PlayerDeathReason.ByNPC(npc.whoAmI), 30, p.direction);
                    }
                }
                int[] posNeg    = { 1, -1 };
                float sX        = posNeg[Main.rand.Next(0, 1)];
                float sY        = posNeg[Main.rand.Next(0, 1)];
                float tDistance = 400f;
                npc.position.X = p.Center.X + (tDistance * sX) + fOne;
                npc.position.Y = p.Center.Y + (tDistance * sY) + fTwo;
                didOnce        = 0;
                portCoolDown   = 180;
            }
            float moveToX  = moveTo.X - npc.Center.X + fOne;
            float moveToY  = moveTo.Y - npc.Center.Y + fTwo;
            float distance = (float)System.Math.Sqrt((double)(moveToX * moveToX + moveToY * moveToY));
            float speed    = 5f;

            if (pDistance > 500)
            {
                speed = 15f;
            }
            distance = speed / distance;
            moveToX *= distance;
            moveToY *= distance;
            if (pDistance > 500)
            {
                pX += fOne * 2;
                pY += fTwo * 2;
                pX *= distance;
                pY *= distance;
            }
            if (didOnce == 0 || pDistance > 500)
            {
                npc.velocity.X = moveToX;
                npc.velocity.Y = moveToY;
                if (pDistance > 500)
                {
                    npc.velocity.X = pX;
                    npc.velocity.Y = pY;
                }
                didOnce = 1;
            }
            if (mode == 4)
            {
                flammenWheel(p);
            }
        }