Exemplo n.º 1
0
        public override void SetDefaults() //MAKE SURE YOU CALL BASE.SETDEFAULTS IF OVERRIDING
        {
            Projectile.width       = 48;
            Projectile.height      = 48;
            Projectile.hostile     = true;
            Projectile.alpha       = 255;
            Projectile.penetrate   = -1;
            Projectile.tileCollide = false;
            Projectile.timeLeft    = 3600;

            CooldownSlot = 1; //not in warning line, test?

            Projectile.GetGlobalProjectile <FargoSoulsGlobalProjectile>().GrazeCheck =
                Projectile =>
            {
                float num6 = 0f;
                if (CanDamage() != false && Collision.CheckAABBvLineCollision(Main.LocalPlayer.Hitbox.TopLeft(), Main.LocalPlayer.Hitbox.Size(), Projectile.Center,
                                                                              Projectile.Center + Projectile.velocity * Projectile.localAI[1], 22f * Projectile.scale + Main.LocalPlayer.GetModPlayer <FargoSoulsPlayer>().GrazeRadius * 2f + Player.defaultHeight, ref num6))
                {
                    return(true);
                }
                return(false);
            };

            Projectile.hide = true; //fixes weird issues on spawn with scaling
            Projectile.GetGlobalProjectile <FargoSoulsGlobalProjectile>().DeletionImmuneRank = 1;
        }
Exemplo n.º 2
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            try
            {
                if (doneDelay)
                {
                    float   point     = 0f;
                    Vector2 endPoint  = (VectorHelper.GetVectorAtAngle(rotation) * 2048);
                    bool    colliding = Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), npcCenter, npcCenter + endPoint, maxThickness, ref point);
                    if (colliding)
                    {
                        Vector2 spawn = (Vector2.Normalize(endPoint) * point) + npcCenter;

                        for (int i = 0; i < Main.rand.Next(1, 16); i++)
                        {
                            Dust.NewDust(spawn, 4, 4, 6);
                        }
                    }
                    return(colliding);
                }
                return(false);
            }
            catch (Exception e)
            {
                Main.NewTextMultiline(e.ToString());
                return(null);
            }
        }
Exemplo n.º 3
0
        public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            if (projHitbox.Intersects(targetHitbox))
                return true;

            float length;
            switch (Projectile.frame)
            {
                case 0: length = 56; break;
                case 1: length = 40; break;
                case 2: length = 54; break;
                case 3: length = 50; break;
                case 4: length = 44; break;
                case 5: length = 56; break;
                case 6: length = 50; break;
                case 7: length = 32; break;
                case 8: length = 34; break;
                case 9: length = 46; break;
                case 10: length = 34; break;
                default: goto case 0;
            }
            length = (float)Math.Sqrt(2 * length * length);
            length *= 0.8f;

            float dummy = 0f;
            Vector2 offset = length / 2 * Projectile.scale * Projectile.rotation.ToRotationVector2();
            Vector2 end = Projectile.Center - offset;
            Vector2 tip = Projectile.Center + offset;

            if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), end, tip, 8f * Projectile.scale, ref dummy))
                return true;

            return false;
        }
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            float   num = 0f;
            Vector2 end = projectile.Center + length * TrueRotation.ToRotationVector2();

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, end, projectile.width, ref num));
        }
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            float   point    = 0f;
            Vector2 endPoint = projectile.Center + projectile.velocity * 1000f;

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, endPoint, 4f, ref point));
        }
Exemplo n.º 6
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            Player player = Main.player[projectile.owner];
            bool   ret    = false;

            if (projectile.ai[1] == 0 && channeling)
            {
                for (int i = 0; i < Main.projectile.Length; i++)
                {
                    Projectile proj = Main.projectile[i];
                    if (proj.active && proj.type == projectile.type && proj.owner == player.whoAmI && proj != projectile)
                    {
                        float   collisionPoint = 0f;
                        Vector2 dir            = proj.Center - projectile.Center;
                        if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + dir, (projectile.width + projectile.height) * 0.5f * projectile.scale, ref collisionPoint))
                        {
                            ret = true;
                        }
                    }
                }
            }
            if (ret)
            {
                return(true);
            }
            return(base.Colliding(projHitbox, targetHitbox));
        }
Exemplo n.º 7
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            Vector2 lineEnd        = projectile.position + Vector2.Normalize(projectile.velocity) * this.length;
            float   collisionPoint = 0f;

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.position, lineEnd, 10f, ref collisionPoint));
        }
Exemplo n.º 8
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            float   point    = 0f;
            Vector2 endPoint = projectile.position + projectile.width * projectile.rotation.ToRotationVector2();

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.position, endPoint, projectile.height, ref point));
        }
Exemplo n.º 9
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            float point = 0f;

            return(projHitbox.Intersects(targetHitbox) ||
                   Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), basePosition, projectile.Center, projectile.width, ref point));
        }
Exemplo n.º 10
0
        //Thank you Iriazul for this!
        public static bool DoesBeamCollide(Rectangle targetHitbox, Vector2 beamStart, float beamAngle, float beamWidth)
        {
            float length   = GetBeamLength(beamStart, beamAngle);
            var   endPoint = beamStart + beamAngle.ToRotationVector2() * length;
            float temp     = 0f;

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), beamStart, endPoint, beamWidth, ref temp));
        }
Exemplo n.º 11
0
 public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
 {
     if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.oldPos[ProjectileID.Sets.TrailCacheLength[projectile.type] - 1] + projectile.Size / 2))
     {
         return(true);
     }
     return(base.Colliding(projHitbox, targetHitbox));
 }
Exemplo n.º 12
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            Player player = Main.player[projectile.owner];
            float  point  = 0f;

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), player.MountedCenter,
                                                     projectile.position, 2, ref point));
        }
Exemplo n.º 13
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            Projectile P     = projectile;
            float      point = 0f;

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), P.Center,
                                                     P.Center + P.velocity * P.ai[1], (float)P.width * scaleUp, ref point));
        }
Exemplo n.º 14
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            Vector2 center = projectile.Center;
            Vector2 end    = center + (projectile.velocity * 4).RotatedBy(angle);
            float   i      = 0;

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), center, end, 5, ref i));
        }
Exemplo n.º 15
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            if (npc == null || !FargoSoulsWorld.EternityMode)
            {
                return(base.Colliding(projHitbox, targetHitbox));
            }

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), ChainOrigin, Projectile.Center));
        }
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            if (attacking)
            {
                return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, new Vector2(projectile.Center.X + flameRange * d, projectile.Center.Y), projectile.height, ref CP));
            }

            return(false);
        }
Exemplo n.º 17
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            float   rot = projectile.ai[0] % 80 / 80f * 6.28f;
            float   x   = (float)Math.Cos(-rot) * 160;
            float   y   = (float)Math.Sin(-rot) * 70;
            Vector2 off = new Vector2(x, y);

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + off));
        }
Exemplo n.º 18
0
 public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
 {
     if (projectile.localAI[0] == 1)
     {
         float point = 0f;
         return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width, ref point));
     }
     return(false);
 }
Exemplo n.º 19
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            Player  player = Main.player[projectile.owner];
            Vector2 unit   = projectile.velocity;
            float   point  = 0f;

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), player.Center,
                                                     player.Center + unit * 2000, (projectile.ai[0] == 0 ? 20 : 44), ref point));
        }
Exemplo n.º 20
0
 public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
 {
     if (projectile.ai[1] == 1)
     {
         return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(),
                                                  new Vector2(projectile.localAI[0], projectile.localAI[1]), projectile.Center));
     }
     return(false);
 }
Exemplo n.º 21
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            Vector2 v2 = projectile.velocity;

            v2.Normalize();
            float point = 0f;

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center,
                                                     projectile.Center - v2 * 230f, 16, ref point));
        }
Exemplo n.º 22
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            float point = 0f;

            if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center - projectile.velocity * 2, projectile.Center, 22, ref point))
            {
                return(true);
            }
            return(null);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Change the way of collision check of the projectile
        /// </summary>
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            Player  p    = Main.player[projectile.owner];
            Vector2 unit = (Main.player[projectile.owner].MountedCenter - _targetPos);

            unit.Normalize();
            float point = 0f;

            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), p.Center - 45f * unit, _targetPos, 24, ref point));
        }
Exemplo n.º 24
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            float num3 = 0f;

            if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 22f * projectile.scale, ref num3))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 25
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            float collisionPoint = 0f;

            if (phase == Phases.ATTACKING && frameY == 4)
            {
                return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center + (projectile.rotation.ToRotationVector2() * 150), projectile.Center - (projectile.rotation.ToRotationVector2() * 150), 30, ref collisionPoint));
            }
            return(false);
        }
Exemplo n.º 26
0
        public override bool?Colliding(Rectangle myRect, Rectangle targetRect)
        {
            float num = 0f;

            if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 22f * projectile.scale, ref num))
            {
                return(true);
            }
            return(null);
        }
Exemplo n.º 27
0
 public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
 {
     if (Lead != null && Lead.active)
     {
         float point = 0f;
         return(projHitbox.Intersects(targetHitbox) ||
                Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Lead.Center, projectile.Center, projectile.width, ref point));
     }
     return(false);
 }
Exemplo n.º 28
0
        public override bool CanHitPlayer(Player target, ref int cooldownSlot)
        {
            float col = 0;

            if ((attack2Timer < 60 || attack2Timer > 600) && npc.ai[3] == 1)
            {
                return(false);
            }
            return(Collision.CheckAABBvLineCollision(target.Hitbox.TopLeft(), target.Hitbox.Size(), BladeStart, BladeTip, bladeWidth, ref col));
        }
Exemplo n.º 29
0
        // Change the way of collision check of the projectile
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            Vector2 unit  = projectile.velocity;
            float   point = 0f;

            // Run an AABB versus Line check to look for collisions, look up AABB collision first to see how it works
            // It will look for collisions on the given line using AABB
            return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Main.npc[(int)projectile.ai[1]].Center + new Vector2(0f, 100f),
                                                     Main.npc[(int)projectile.ai[1]].Center + new Vector2(0f, 100f) + unit * Distance, 22, ref point));
        }
Exemplo n.º 30
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            float collisionPoint9 = 0f;

            if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * 6f, 10f * projectile.scale, ref collisionPoint9))
            {
                return(true);
            }
            return(false);
        }