Example #1
0
        public override void UpdateEffects(Player player)
        {
            if (Math.Abs(player.velocity.X) > player.mount.DashSpeed - player.mount.RunSpeed / 2f)
            {
                player.noKnockback = true;

                Rectangle rect = player.getRect();
                //Tweak hitbox to be the Basilisks head
                rect.Width = 2;
                rect.Height = 2;
                if (player.direction == 1)
                {
                    rect.Offset(player.width - 1, 0);
                }
                rect.Offset(0, player.height - 19);
                rect.Inflate(28, 16);

                for (int n = 0; n < Main.maxNPCs; n++)
                {
                    NPC npc = Main.npc[n];
                    if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.immune[player.whoAmI] == 0)
                    {
                        Rectangle rect2 = npc.getRect();
                        if (rect.Intersects(rect2) && (npc.noTileCollide || Collision.CanHit(player.position, player.width, player.height, npc.position, npc.width, npc.height)))
                        {
                            float damage = BasiliskMount.damage * player.minionDamage;
                            float knockback = BasiliskMount.knockback * player.minionKB;
                            int direction = player.direction;
                            if (player.velocity.X < 0f)
                            {
                                direction = -1;
                            }
                            if (player.velocity.X > 0f)
                            {
                                direction = 1;
                            }
                            if (player.whoAmI == Main.myPlayer)
                            {
                                player.ApplyDamageToNPC(npc, (int)damage, knockback, direction, false);
                            }
                            npc.immune[player.whoAmI] = 30;
                            player.immune = true;
                            player.immuneTime = 6;
                            return;
                        }
                    }
                }
            }
        }