Beispiel #1
0
        /// <summary>
        /// Performs MagicPickup
        /// </summary>
        /// <param name="player"></param>
        public void Pickup(Player player)
        {
            Vector4 points = new Vector4(player.position.X - 50, player.position.X + 50, player.position.Y - 50, player.position.Y + 50);

            foreach (Item i in Main.item)
            {
                if (i != null && !i.IsAir && NotStorage(i))
                {
                    SGlobalItem item = i.GetGlobalItem <SGlobalItem>();
                    if (InRange(i) && !player.ItemSpace(i) && contained.Count < limit)
                    {
                        item.pickup = this;
                    }
                }
            }
            bool InRange(Item e) => e.position.X > points.X && e.position.X <points.Y && e.position.Y> points.Z && e.position.Y < points.W;
        }
Beispiel #2
0
        public override void AI()
        {
            npc.direction = 1;
            //targetTimer++;
            if (npc.velocity.Y < 0 && !hasJumped)
            {
                hasJumped = true;
            }
            if (hasJumped && npc.velocity.Y == 0)
            {
                hasJumped = false;
            }
            if (hasJumped && npc.velocity.Y < 0)
            {
                npc.velocity.Y += 4f;
                Main.PlaySound(SoundLoader.customSoundType, npc.Center, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/Tarr_Bounce"));
                if (Main.rand.Next(15) == 0)
                {
                    Main.PlaySound(SoundLoader.customSoundType, npc.Center, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/Tarr_Grunt"));
                }
            }
            //music = mod.GetSoundSlot(SoundType.Music, "Sounds/Music/RavenousRainbows");
            music         = MusicID.GoblinInvasion;
            musicPriority = MusicPriority.BossHigh;
            if (Main.rand.Next(450) == 0)
            {
                int a = Main.rand.Next(2);
                if (a == 0)
                {
                    Main.PlaySound(SoundLoader.customSoundType, npc.Center, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/Tarr_Idle1"));
                }
                if (a == 1)
                {
                    Main.PlaySound(SoundLoader.customSoundType, npc.Center, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/Tarr_Idle2"));
                }
            }
            if (appen != -1 && Main.npc[appen].ai[3] == 30)
            {
                catchTarget          = false;
                Main.npc[appen].life = int.MinValue;
                appen = -1;
            }
            if (appen != -1 && Main.npc[appen].ai[3] == 21f)
            {
                Main.npc[appen].life = int.MinValue;
                appen     = -1;
                replicate = true;
            }
            //npc.aiAction = 69;
            if (target == null || !target.active)
            {
                SetTarget();
            }
            foreach (Item item in Main.item)
            {
                if (ItemNearTarr(item, npc))
                {
                    SGlobalItem gi = item.GetGlobalItem <SGlobalItem>();
                    gi.originalVelo = item.velocity;
                    gi.flingVelo    = new Vector2(npc.velocity.X * 1.25f, npc.velocity.Y * 1.25f);
                    gi.flingTime    = 45;
                    gi.flinged      = true;
                }
            }
            if (target != null && target.active)
            {
                if (Main.rand.Next(750) == 0)
                {
                    Main.PlaySound(SoundLoader.customSoundType, npc.Center, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/Tarr_Grunt"));
                }
                Vector2 velocity = new Vector2((float)Math.Sin((double)(Math.PI * 2 * mH / 300f)) * 0.5f, 0f);
                mH      += 1f;
                velocity = Vector2.UnitX * velocity.Length();
                if (target.position.X > npc.position.X)
                {
                    npc.velocity.X = velocity.X * 4;
                }
                else if (target.position.X < npc.position.X)
                {
                    npc.velocity.X = velocity.X * -4;
                }
                if (catchTarget)
                {
                    npc.velocity.Y  = 0f;
                    npc.velocity.X *= 0.5f;
                }
                #region

                /*
                 * if (!catchTarget)
                 *  npc.velocity.X = Direction();
                 * else
                 * {
                 *  npc.velocity.Y = 0f;
                 *  npc.velocity.X *= 0.5f;
                 * }
                 * float Direction()
                 * {
                 *  if (target.position.X > npc.position.X && target.active)
                 *      return 4f;
                 *  else if (target.position.X < npc.position.X && target.active)
                 *      return -4f;
                 *  return 0f;
                 * }
                 */
                #endregion
            }
            if (!catchTarget)
            {
                SnatchATarget();
            }
            if (replicate)
            {
                rep++;
                if (rep > 120)
                {
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, ModContent.NPCType <TheTarr>());
                    rep         = 0;
                    catchTarget = false;
                    replicate   = false;
                    Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Gore1"), 1f);
                    for (int a = 0; a < 3; a++)
                    {
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Gore2"), 1f);
                    }
                    Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Gore3"), 1f);
                    //int newTarr = NPC.NewNPC()
                }
            }
            if (npc.HasBuff(BuffID.Wet) || npc.wet)
            {
                npc.takenDamageMultiplier = 250000f;
            }
            else
            {
                npc.life = npc.lifeMax;
                npc.takenDamageMultiplier = -50f;
            }
            if (appen != -1 && Main.npc[appen].ai[3] == 69f)
            {
                catchTarget          = false;
                replicate            = false;
                Main.npc[appen].life = int.MinValue;
                appen     = -1;
                replicate = true;
            }
            bool ItemNearTarr(Item item, NPC npc)
            {
                Vector2 high = new Vector2(npc.position.X + 50, npc.position.Y + 75);
                Vector2 low  = new Vector2(npc.position.X - 50, npc.position.Y - 50);

                return(item.position.X > low.X && item.position.X < high.X && item.position.Y > low.Y && item.position.Y < high.Y);
            }
        }
 public static void ForceDiscard()
 {
     for (int a = 0; a < 255; a++)
     {
         Player parti = Main.player[a];
         if (IsParticpant(a))
         {
             for (int b = 0; b < 58; b++)
             {
                 Item item = parti.inventory[b];
                 if (!item.IsAir)
                 {
                     SGlobalItem sg = item.GetGlobalItem <SGlobalItem>();
                     if (sg.IsContrabande(item))
                     {
                         sg.ForceDiscard(parti, 1);
                     }
                     //Main.NewText($"{sg.IsContrabande(item)} {item.Name}");
                 }
             }
             for (int b = 0; b < 19; b++)
             {
                 Item item = parti.armor[b];
                 if (!item.IsAir)
                 {
                     SGlobalItem sg = item.GetGlobalItem <SGlobalItem>();
                     if (sg.IsContrabande(item))
                     {
                         sg.ForceDiscard(parti, 2);
                     }
                 }
             }
             for (int b = 0; b < 9; b++)
             {
                 Item item = parti.dye[b];
                 if (!item.IsAir)
                 {
                     SGlobalItem sg = item.GetGlobalItem <SGlobalItem>();
                     if (sg.IsContrabande(item))
                     {
                         sg.ForceDiscard(parti, 3);
                     }
                 }
             }
             for (int b = 0; b < 4; b++)
             {
                 Item item = parti.miscEquips[b];
                 if (!item.IsAir)
                 {
                     SGlobalItem sg = item.GetGlobalItem <SGlobalItem>();
                     if (sg.IsContrabande(item))
                     {
                         sg.ForceDiscard(parti, 4);
                     }
                 }
             }
             for (int b = 0; b < 4; b++)
             {
                 Item item = parti.miscDyes[b];
                 if (!item.IsAir)
                 {
                     SGlobalItem sg = item.GetGlobalItem <SGlobalItem>();
                     if (sg.IsContrabande(item))
                     {
                         sg.ForceDiscard(parti, 5);
                     }
                 }
             }
             for (int b = 0; b < 40; b++)
             {
                 Item item1 = parti.bank.item[b];
                 Item item2 = parti.bank2.item[b];
                 Item item3 = parti.bank3.item[b];
                 if (!item1.IsAir)
                 {
                     SGlobalItem sg1 = item1.GetGlobalItem <SGlobalItem>();
                     if (item1.GetGlobalItem <SGlobalItem>().IsContrabande(item1))
                     {
                         sg1.ForceDiscard(parti, 6);
                     }
                 }
                 if (!item2.IsAir)
                 {
                     SGlobalItem sg2 = item2.GetGlobalItem <SGlobalItem>();
                     if (item2.GetGlobalItem <SGlobalItem>().IsContrabande(item2))
                     {
                         sg2.ForceDiscard(parti, 7);
                     }
                 }
                 if (!item3.IsAir)
                 {
                     SGlobalItem sg3 = item3.GetGlobalItem <SGlobalItem>();
                     if (item3.GetGlobalItem <SGlobalItem>().IsContrabande(item3))
                     {
                         sg3.ForceDiscard(parti, 8);
                     }
                 }
             }
         }
     }
 }