Exemplo n.º 1
0
 private void ChaosPearlAttack()
 {
     if (Main.netMode != 1 && attackTimer % 30 == 0 && attackTimer < 90)
     {
         ChaosSpirit2 spirit     = Main.npc[spiritIndex].modNPC as ChaosSpirit2;
         Player       player     = Main.player[spirit.RandomTarget()];
         Vector2      difference = player.Center - npc.Center;
         if (difference != Vector2.Zero)
         {
             difference.Normalize();
             int damage = 100;
             if (Main.expertMode)
             {
                 damage = (int)(damage * 1.5f / 2f);
             }
             Projectile.NewProjectile(npc.Center, 8f * difference, mod.ProjectileType("ChaosPearl"), damage, 0f, Main.myPlayer, colorType, player.whoAmI);
         }
     }
     attackTimer++;
     if (attackTimer > 90)
     {
         attack      = 0;
         attackTimer = 0;
     }
 }
Exemplo n.º 2
0
 private void LaserAttack()
 {
     attackTimer++;
     if (attackTimer == 300 && Main.netMode != 1)
     {
         ChaosSpirit2 spirit   = Main.npc[spiritIndex].modNPC as ChaosSpirit2;
         float        rotation = spirit.armRotation + (colorType / 6f) * MathHelper.TwoPi;
         float        startRot = rotation - MathHelper.Pi / 3f;
         float        endRot   = rotation + MathHelper.Pi / 3f;
         if (Main.rand.Next(2) == 0)
         {
             float temp = startRot;
             startRot = endRot;
             endRot   = temp;
         }
         int damage = 360;
         if (Main.expertMode)
         {
             damage = (int)(damage * 1.5f / 2f);
         }
         int proj = Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("ChaosRay"), damage, 0f, Main.myPlayer, npc.whoAmI, startRot);
         Main.projectile[proj].localAI[0] = endRot;
         NetMessage.SendData(27, -1, -1, null, proj);
     }
     if (attackTimer == 300)
     {
         Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, 104);
     }
     if (attackTimer > 540)
     {
         attack      = 0;
         attackTimer = 0;
     }
 }
Exemplo n.º 3
0
        private bool?CanBeHitByPlayer(Player player)
        {
            ChaosSpirit2 spirit = Main.npc[spiritIndex].modNPC as ChaosSpirit2;

            if (spirit != null && !spirit.targets.Contains(player.whoAmI))
            {
                return(false);
            }
            return(null);
        }
Exemplo n.º 4
0
        public override void AI()
        {
            if (!Main.dedServ)
            {
                UpdateChaosOrbs();
            }
            if (npc.localAI[0] == 0f)
            {
                npc.GivenName  = GetName();
                npc.localAI[0] = 1f;
            }
            npc.timeLeft = NPC.activeTime;
            npc.life     = npc.lifeMax;
            NPC center = Main.npc[spiritIndex];

            if (!center.active || center.type != mod.NPCType("ChaosSpirit2"))
            {
                npc.active = false;
                return;
            }
            ChaosSpirit2 spirit = center.modNPC as ChaosSpirit2;

            if (spirit == null)
            {
                return;
            }
            float   rotation = spirit.armRotation + (colorType / 6f) * MathHelper.TwoPi;
            Vector2 target   = armLength * rotation.ToRotationVector2();
            Vector2 move     = target - offset;

            if (move.Length() > 4f)
            {
                move.Normalize();
                move *= 2f;
            }
            offset    += move;
            npc.Center = center.Center + offset;
            DoAttack();
        }