public override void SafeSetDefaults()
        {
            item.damage       = 25;
            item.ranged       = true;
            item.width        = 40;
            item.height       = 20;
            item.useTime      = 23;
            item.useAnimation = 23;
            item.useStyle     = ItemUseStyleID.HoldingOut;
            item.noMelee      = true;
            item.knockBack    = 7;
            item.value        = 10000;
            item.rare         = ItemRarityID.Yellow;
            item.autoReuse    = true;
            item.shoot        = ProjectileID.GrenadeI;
            item.shootSpeed   = 10;
            item.useAmmo      = AmmoID.Rocket;

            PrimarySounds   = new LegacySoundStyle[4];
            SecondarySounds = null;

            for (int n = 1; n <= PrimarySounds.Length; n++)
            {
                PrimarySounds[n - 1] =
                    mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Item, SoundLocation + n);
            }
        }
Beispiel #2
0
        public override void SafeSetDefaults()
        {
            item.autoReuse    = true;
            item.useTime      = 10;
            item.useAnimation = 10;
            item.useAmmo      = AmmoID.Bullet;
            item.useStyle     = ItemUseStyleID.HoldingOut;
            item.crit         = 15;
            item.width        = 66;
            item.height       = 36;
            item.shoot        = 10;
            //item.UseSound = SoundID.Item11;
            item.damage     = 33;
            item.shootSpeed = 10f;
            item.noMelee    = true;
            item.value      = Item.buyPrice(0, 15, 0, 50);
            item.knockBack  = 4f;
            item.rare       = ItemRarityID.Yellow;

            PrimarySounds   = new LegacySoundStyle[4];
            SecondarySounds = new LegacySoundStyle[4];

            for (int n = 1; n <= PrimarySounds.Length; n++)
            {
                PrimarySounds[n - 1] =
                    mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Item, SoundLocation + "Primary" + n);
            }
            for (int n = 1; n <= SecondarySounds.Length; n++)
            {
                SecondarySounds[n - 1] =
                    mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Item, SoundLocation + "Secondary" + n);
            }
        }
        /// <summary>
        /// Here to illustrate PrimarySounds and SecondarySounds
        /// </summary>
        public override void SafeSetDefaults()
        {
            /*
             * These two arrays hold the sounds which will be used by the weapon
             * The names (Primary and Secondary) are all but semantics and do not indicate the function of the sounds
             * In most cases the names do indicate the use of the sounds but this can be subverted if needed
             * The length of the arrays should be equal to the number of unique sounds used by the weapon
             * For readability, PrimarySounds should be used before SecondarySounds and SecondarySounds should be nullified if PrimarySounds is not used
             */
            PrimarySounds   = new LegacySoundStyle[1];  // How to initialize the array when used
            SecondarySounds = null;                     // How to nullify the array when not used

            // This for loop shows the most common way of populating the sound arrays
            for (int n = 1; n <= PrimarySounds.Length; n++)    // n is initialized to 1 instead of 0 to allow for proper name spacing and readability
            {
                PrimarySounds[n - 1] =
                    // When populating the array it is important to remember the file path the sounds are located in
                    // The Terraria.ModLoader.SoundType.Type must be the same as the sounds main folder (clarification in a moment)
                    // Failure to do so will causes the sounds to not get loaded and the arrays will be filled with nulls
                    // To avoid this, ensure the sounds type folder to be the same as the SoundType
                    //    The possible sound types are: Custom, Item, Misc, NPCHit, NPCKilled
                    // The sounds filepath should have the same type as its original subfolder (the folder under Sounds)
                    // If additional clarification is needed either reference existing ExplosiveWeapons and ExplosivesProjectiles (and their sound locations)
                    // Or ask in the discord\
                    mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Item, SoundLocation + n);
            }
            // If SecondarySounds is also used, a second for loop will be needed
        }
Beispiel #4
0
 public override void SafeSetDefaults()
 {
     pickPower = 70;
     radius    = 20;
     projectile.tileCollide = true;
     projectile.width       = 32;
     projectile.height      = 40;
     projectile.aiStyle     = 16;
     projectile.friendly    = true;
     projectile.penetrate   = -1;
     projectile.timeLeft    = Int32.MaxValue;
     //projectile.extraUpdates = 1;
     Terraria.ModLoader.SoundType customType = Terraria.ModLoader.SoundType.Custom;
     indicatorSound = mod.GetLegacySoundSlot(customType, explodeSoundsLoc + "timer");
     primedSound    = mod.GetLegacySoundSlot(customType, explodeSoundsLoc + "time_to_explode");
     if (!Main.dedServ && indicatorSound != null || primedSound != null) //Checking for nulls might fix the error
     {
         indicatorSound = indicatorSound.WithPitchVariance(0f).WithVolume(0.5f);
         primedSound    = primedSound.WithPitchVariance(0f).WithVolume(0.5f);
     }
     else if (indicatorSound != null || primedSound != null)
     {
         indicatorSound = mod.GetLegacySoundSlot(customType, explodeSoundsLoc + "timer");
         primedSound    = mod.GetLegacySoundSlot(customType, explodeSoundsLoc + "time_to_explode");
     }
     explodeSounds = new LegacySoundStyle[4];
     for (int num = 1; num <= explodeSounds.Length; num++)
     {
         explodeSounds[num - 1] = mod.GetLegacySoundSlot(customType, explodeSoundsLoc + "Bomb_" + num);
     }
 }
Beispiel #5
0
        public override void SafeSetDefaults()
        {
            item.damage       = 26;
            item.width        = 78;
            item.height       = 32;
            item.useTime      = 45;
            item.useAnimation = 45;
            item.useStyle     = ItemUseStyleID.HoldingOut;
            item.noMelee      = true; //so the item's animation doesn't do damage
            item.knockBack    = 2.5f;
            item.value        = 10000;
            item.rare         = ItemRarityID.LightRed;
            item.autoReuse    = true;
            item.shoot        = ProjectileID.Bullet;
            item.shootSpeed   = 11;
            item.useAmmo      = AmmoID.Bullet;

            PrimarySounds   = new LegacySoundStyle[4];
            SecondarySounds = new LegacySoundStyle[4];

            for (int n = 1; n <= PrimarySounds.Length; n++)
            {
                PrimarySounds[n - 1] =
                    mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Item, SoundLocation + "Primary" + n);
            }
            for (int n = 1; n <= SecondarySounds.Length; n++)
            {
                SecondarySounds[n - 1] =
                    mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Item, SoundLocation + "Secondary" + n);
            }
        }
        public override void SafeSetDefaults()
        {
            item.damage       = 15;
            item.width        = 40;
            item.height       = 20;
            item.useTime      = 30;
            item.useAnimation = 30;
            item.useStyle     = ItemUseStyleID.HoldingOut;
            item.noMelee      = true; //so the item's animation doesn't do damage
            item.knockBack    = 4;
            item.value        = 10000;
            item.rare         = ItemRarityID.Blue;
            item.autoReuse    = true;
            item.shoot        = 133; //idk why but all the guns in the vanilla source have this
            item.shootSpeed   = 8;
            item.useAmmo      = AmmoID.Rocket;

            PrimarySounds   = new LegacySoundStyle[4];
            SecondarySounds = null;

            for (int n = 1; n <= PrimarySounds.Length; n++)
            {
                PrimarySounds[n - 1] =
                    mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Item, SoundLocation + n);
            }
        }
        public override void SafeSetDefaults()
        {
            item.damage       = 18;
            item.width        = 46;
            item.height       = 36;
            item.useTime      = 50;
            item.useAnimation = 50;
            item.useStyle     = ItemUseStyleID.HoldingOut;
            item.noMelee      = true; //so the item's animation doesn't do damage
            item.knockBack    = 7;
            item.crit         = 11;
            item.value        = 10000;
            item.rare         = ItemRarityID.Green;
            item.autoReuse    = true;
            item.shoot        = 10;
            item.shootSpeed   = 15;
            item.useAmmo      = AmmoID.Rocket;

            PrimarySounds   = new LegacySoundStyle[4];
            SecondarySounds = null;

            for (int n = 1; n <= PrimarySounds.Length; n++)
            {
                PrimarySounds[n - 1] =
                    mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Item, SoundLocation + n);
            }
        }
Beispiel #8
0
 protected DBTTool(string displayName, int width, int height, int value, int rarity,
                   int useStyle, LegacySoundStyle useSound, int useAnimation, int useTime) : base(displayName, "", width, height, value, 0, rarity)
 {
     _useStyle     = useStyle;
     _useSound     = useSound;
     _useAnimation = useAnimation;
     _useTime      = useTime;
 }
Beispiel #9
0
 protected DBTConsumable(string displayName, string tooltip, int width, int height, int value, int rarity,
                         int useStyle, bool useTurn, LegacySoundStyle useSound, int useAnimation, int useTime) : base(displayName, tooltip, width, height, value, 0, rarity)
 {
     _useStyle     = useStyle;
     _useTurn      = useTurn;
     _useSound     = useSound;
     _useAnimation = useAnimation;
     _useTime      = useTime;
 }
Beispiel #10
0
        public static SlotId PlayVanillaSound(LegacySoundStyle soundId, Vector2 position, float volume = 1f, float pitchVariance = 0f)
        {
            if (Main.dedServ)
            {
                return(SlotId.Invalid);
            }

            if (position == Vector2.Zero)
            {
                return(Main.PlayTrackedSound(soundId.WithVolume(volume).WithPitchVariance(pitchVariance), position));
            }

            return(Main.PlayTrackedSound(soundId.WithVolume(volume).WithPitchVariance(pitchVariance), position));
        }
 public override void SafeSetDefaults()
 {
     projectile.tileCollide = true;      //checks to see if the projectile can go through tiles
     projectile.width       = 22;        //This defines the hitbox width
     projectile.height      = 22;        //This defines the hitbox height
     projectile.aiStyle     = 16;        //How the projectile works, 16 is the aistyle Used for: Grenades, Dynamite, Bombs, Sticky Bomb.
     projectile.friendly    = true;      //Tells the game whether it is friendly to players/friendly npcs or not
     projectile.penetrate   = -1;        //Tells the game how many enemies it can hit before being destroyed
     projectile.timeLeft    = 100;       //The amount of time the projectile is alive for
     explodeSounds          = new LegacySoundStyle[2];
     for (int num = 1; num <= explodeSounds.Length; num++)
     {
         explodeSounds[num - 1] = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, explodeSoundsLoc + num);
     }
 }
Beispiel #12
0
 public override void SafeSetDefaults()
 {
     radius = 10;
     projectile.tileCollide = true;
     projectile.width       = 10;
     projectile.height      = 32;
     projectile.aiStyle     = 16;
     projectile.friendly    = true;
     projectile.penetrate   = -1;
     projectile.timeLeft    = 100;
     explodeSounds          = new LegacySoundStyle[3];
     for (int num = 1; num <= explodeSounds.Length; num++)
     {
         explodeSounds[num - 1] = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, explodeSoundsLoc + num);
     }
 }
Beispiel #13
0
        public override void SetDefaults()
        {
            item.width     = 38;
            item.height    = 38;
            item.value     = 10000;
            item.rare      = ItemRarityID.Cyan;
            item.accessory = true;

            EndSound    = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/Custom/Novabooster/NovaboosterEnd");
            EngineSound = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/Custom/Novabooster/Novabooster");
            if (!Main.dedServ && EngineSound != null && EndSound != null)
            {
                EngineSound = EngineSound.WithVolume(0.3f);
                EndSound    = EndSound.WithVolume(0.4f);
            }
        }
        public void DoPortableChest <T>(ref int whoAmI, ref bool toggle) where T : StorageProjectile, new()
        {
            int projectileType        = ModContent.ProjectileType <T>();
            T   instance              = new T();
            int bankID                = instance.ChestType;
            LegacySoundStyle useSound = instance.UseSound;

            if (Main.projectile[whoAmI].active && Main.projectile[whoAmI].type == projectileType)
            {
                int oldChest = player.chest;
                player.chest = bankID;
                toggle       = true;

                int num17 = (int)((player.position.X + player.width * 0.5) / 16.0);
                int num18 = (int)((player.position.Y + player.height * 0.5) / 16.0);
                player.chestX = (int)Main.projectile[whoAmI].Center.X / 16;
                player.chestY = (int)Main.projectile[whoAmI].Center.Y / 16;
                if ((oldChest != bankID && oldChest != -1) || num17 < player.chestX - Player.tileRangeX || num17 > player.chestX + Player.tileRangeX + 1 || num18 < player.chestY - Player.tileRangeY || num18 > player.chestY + Player.tileRangeY + 1)
                {
                    whoAmI = -1;
                    if (player.chest != -1)
                    {
                        Main.PlaySound(useSound);
                    }

                    if (oldChest != bankID)
                    {
                        player.chest = oldChest;
                    }
                    else
                    {
                        player.chest = -1;
                    }

                    Recipe.FindRecipes();
                }
            }
            else
            {
                Main.PlaySound(useSound);

                whoAmI       = -1;
                player.chest = BankID.None;
                Recipe.FindRecipes();
            }
        }
Beispiel #15
0
 public override void SafeSetDefaults()
 {
     IgnoreTrinkets         = true;
     radius                 = 20;
     pickPower              = -2;
     projectile.tileCollide = true;
     projectile.width       = 22;
     projectile.height      = 22;
     projectile.aiStyle     = 16;
     projectile.friendly    = true;
     projectile.penetrate   = 20;
     projectile.timeLeft    = 140;
     explodeSounds          = new LegacySoundStyle[4];
     for (int num = 1; num <= explodeSounds.Length; num++)
     {
         explodeSounds[num - 1] = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, explodeSoundsLoc + num);
     }
 }
        protected void ResumeVelocity(float speed = 10, LegacySoundStyle playSound = null)
        {
            if (playSound != null)
            {
                Main.PlaySound(playSound, projectile.Center);
            }

            projectile.friendly = DamageTeam[0];
            projectile.hostile  = DamageTeam[1];
            projectile.alpha    = 0;

            Vector2 velocity = Main.MouseWorld - Player.Center;

            velocity.Normalize();
            velocity *= speed;

            projectile.velocity = velocity;
        }
Beispiel #17
0
        public void PlaySound()
        {
            var listOfFieldNames = typeof(SoundID).GetFields();
            var sound            = listOfFieldNames[soundId].GetValue(null);

            float vol = (volume / 100f);

            if (vol < 0)
            {
                vol = 0;
            }
            if (vol > 1)
            {
                vol = 1;
            }
            float pitch = (this.pitch - 100) / 100f * 0.9f;

            if (sound is LegacySoundStyle)
            {
                LegacySoundStyle snd = sound as LegacySoundStyle;
                vol *= snd.Volume;

                if (global)
                {
                    Main.PlaySound(snd.SoundId, -1, -1, snd.Style, vol, pitch);
                }
                else
                {
                    Main.PlaySound(snd.SoundId, Position.X * 16, Position.Y * 16, snd.Style, vol, pitch);
                }
            }
            else if (sound is int)
            {
                int snd = (int)sound;
                if (global)
                {
                    Main.PlaySound(snd, -1, -1, 1, vol, pitch);
                }
                else
                {
                    Main.PlaySound(snd, Position.X * 16, Position.Y * 16, 1, vol, pitch);
                }
            }
        }
Beispiel #18
0
        public override void SafeSetDefaults()
        {
            radius    = 0;
            pickPower = 40;
            projectile.tileCollide = true;
            projectile.width       = 10;
            projectile.height      = 10;
            projectile.aiStyle     = 16;
            projectile.friendly    = true;
            projectile.penetrate   = -1;
            projectile.timeLeft    = 120;
            projectile.damage      = 0;

            drawOffsetX       = -15;
            drawOriginOffsetY = -15;
            explodeSounds     = new LegacySoundStyle[] {
                mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, explodeSoundsLoc)
            };
        }
Beispiel #19
0
        protected SurvivariaItem(string displayName, string tooltip, int width, int height, int value = 0, int rarity = ItemRarityID.White, int hungerAmount = 0, int thirstAmount = 0, LegacySoundStyle eatSound = null, int buffApplied = 0, int buffTime = 0, int maxStack = 999)
        {
            _displayName = displayName;
            _tooltip     = tooltip;

            _width  = width;
            _height = height;

            Value    = value;
            Rarity   = rarity;
            MaxStack = maxStack;
            EatSound = eatSound;

            BuffApplied = buffApplied;
            BuffTime    = buffTime;

            HungerAmount = hungerAmount;
            ThirstAmount = thirstAmount;
        }
 public override void SafeSetDefaults()
 {
     pickPower = -2;
     radius    = 0;
     projectile.tileCollide = true;
     projectile.width       = 16;
     projectile.height      = 32;
     projectile.aiStyle     = 16;
     projectile.friendly    = true;
     projectile.penetrate   = -1;
     projectile.timeLeft    = 45;
     projectile.damage      = 0;
     //projectile.light = .9f;
     //projectile.glowMask = 2;
     explodeSounds = new LegacySoundStyle[4];
     for (int num = 1; num <= explodeSounds.Length; num++)
     {
         explodeSounds[num - 1] = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, explodeSoundsLoc + num);
     }
 }
Beispiel #21
0
 private void ShootOneLaser(Motherboard boss)
 {
     // this code is still poop
     try
     {
         int ai0 = _lastSignalDrone == -1 ? boss.npc.whoAmI : _signalDrones[_lastSignalDrone];
         ++_lastSignalDrone;
         var zapSound = new LegacySoundStyle(SoundID.Trackable, TremorUtils.GetIdForSoundName($"dd2_lightning_aura_zap_{Main.rand.Next(4)}"));
         Main.PlayTrackedSound(zapSound.WithPitchVariance(Main.rand.NextFloat() * .5f).WithVolume(Main.soundVolume * 1.5f));
         int newProj = Projectile.NewProjectile(boss.npc.Center.X, boss.npc.Center.Y, 0, 0,
                                                boss.mod.ProjectileType("projMotherboardLaser"),
                                                LaserDamage, LaserKb, 0, ai0, _signalDrones[_lastSignalDrone]);
         if (_lastSignalDrone == 0)
         {
             Main.projectile[newProj].localAI[1] = 1;
         }
     }
     catch
     {
         // POOP I TELL YOU
     }
 }
Beispiel #22
0
        public override void AI()
        {
            timer--;
            float max = 400f;

            for (int i = 0; i < Main.npc.Length; i++)
            {
                NPC nPC = Main.npc[i];
                if (nPC.active && !nPC.friendly && nPC.damage > 0 && !nPC.dontTakeDamage && Vector2.Distance(projectile.Center, nPC.Center) <= max)
                {
                    int type = ProjectileID.MiniRetinaLaser;
                    LegacySoundStyle sound = SoundID.Item11;
                    switch (Main.rand.Next(2))
                    {
                    case 0:
                        type  = ProjectileID.MiniRetinaLaser;
                        sound = SoundID.Item33;
                        break;

                    case 1:
                        type  = ProjectileID.CursedFlameFriendly;
                        sound = SoundID.Item20;
                        break;

                    default: break;
                    }
                    float   Speed          = 6f;
                    float   rotation       = (float)Math.Atan2(projectile.Center.Y - nPC.Center.Y, projectile.Center.X - nPC.Center.X);
                    Vector2 perturbedSpeed = new Vector2((float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1));
                    if (timer <= 0)
                    {
                        Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, type, projectile.damage, 0f, Main.myPlayer, 0f, 0f);
                        Main.PlaySound(sound, projectile.position);
                        timer = Main.rand.Next(15, 40);
                    }
                }
            }
        }
Beispiel #23
0
        /// <summary>
        /// A more flexible variant of `Main.PlaySound` to allow adjusting volume and position.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="sound"></param>
        /// <param name="position"></param>
        /// <param name="volume"></param>
        public static void PlaySound(string name, LegacySoundStyle sound, Vector2 position, float volume = 1f)
        {
            if (Main.netMode == NetmodeID.Server)
            {
                return;
            }

            var sndHelp = ModContent.GetInstance <SoundLibraries>();

            if (sndHelp.Sounds.ContainsKey(name))
            {
                sound = sndHelp.Sounds[name];
            }

            try {
                sound = sound.WithVolume(volume);
                sndHelp.Sounds[name] = sound;
            } catch (Exception e) {
                throw new ModLibsException("Sound load issue.", e);
            }

            Main.PlaySound(sound, position);
        }
Beispiel #24
0
 public override void SafeSetDefaults()
 {
     pickPower = 70;
     radius    = 80;
     projectile.tileCollide = true;
     projectile.width       = 40;
     projectile.height      = 40;
     projectile.aiStyle     = 16;
     projectile.friendly    = true;
     projectile.penetrate   = -1;
     projectile.timeLeft    = 800;
     //projectile.scale = 1.5f;
     fuseSound = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, explodeSoundsLoc + "Wick");
     if (!Main.dedServ)
     {
         fuseSound = fuseSound.WithVolume(0.5f);
     }
     explodeSounds = new LegacySoundStyle[2];
     for (int num = 1; num <= explodeSounds.Length; num++)
     {
         explodeSounds[num - 1] = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, explodeSoundsLoc + num);
     }
 }
Beispiel #25
0
        public override void SetDefaults()
        {
            item.CloneDefaults(ItemID.ChainGun);
            LegacySoundStyle us = item.UseSound;

            item.CloneDefaults(ItemID.Sandgun);
            item.UseSound     = us;
            item.damage       = 27;
            item.ranged       = true;
            item.noMelee      = true;
            item.width        = 44;
            item.height       = 24;
            item.useAnimation = item.useTime;
            item.useTime      = 7;
            item.useAnimation = 7;
            //item.useStyle = 5;
            item.knockBack *= 2;
            item.value     *= 2;
            item.rare       = ItemRarityID.Pink;
            item.shoot      = 42;       // ModContent.ProjectileType<Sandblast_0Normal>();
            item.useAmmo    = AmmoID.Sand;
            //item.shoot = ProjectileID.DD2FlameBurstTowerT1Shot;
            //item.shootSpeed = 12.5f;
        }
Beispiel #26
0
        public static KeyValuePair <uint, SoundEffectInstance> PlayCustomSound(string soundId, Vector2 position, float volume = 1f, float pitchVariance = 0f)
        {
            if (Main.dedServ)
            {
                return(new KeyValuePair <uint, SoundEffectInstance>(InvalidSlot, null));
            }

            uint             slotId = InvalidSlot;
            LegacySoundStyle style  = GetCustomStyle(soundId, volume, pitchVariance);

            SoundEffectInstance sound = null;

            if (position == Vector2.Zero)
            {
                sound = Main.PlaySound(style);
            }
            else
            {
                sound = Main.PlaySound(style, position);
            }

            slotId = (uint)DBTMod.Instance.GetSoundSlot(SoundType.Custom, soundId);
            return(new KeyValuePair <uint, SoundEffectInstance>(slotId, sound));
        }
        private static bool QuickBuff(Player player, ref LegacySoundStyle sound)
        {
            if (!ModContent.GetInstance <PortableStorageConfig>().AlchemistBagQuickBuff)
            {
                return(false);
            }

            foreach (Item item in player.inventory.OfType <AlchemistBag>().SelectMany(x => x.Handler.Items))
            {
                if (player.CountBuffs() == player.buffType.Length)
                {
                    return(true);
                }

                if (item.stack > 0 && item.type > 0 && item.buffType > 0 && !item.summon && item.buffType != 90)
                {
                    int  buffType = item.buffType;
                    bool useItem  = ItemLoader.CanUseItem(item, player);
                    for (int i = 0; i < player.buffType.Length; i++)
                    {
                        if (buffType == 27 && (player.buffType[i] == buffType || player.buffType[i] == 101 || player.buffType[i] == 102))
                        {
                            useItem = false;
                            break;
                        }

                        if (player.buffType[i] == buffType)
                        {
                            useItem = false;
                            break;
                        }

                        if (Main.meleeBuff[buffType] && Main.meleeBuff[player.buffType[i]])
                        {
                            useItem = false;
                            break;
                        }
                    }

                    if (Main.lightPet[item.buffType] || Main.vanityPet[item.buffType])
                    {
                        for (int buffIndex = 0; buffIndex < player.buffType.Length; buffIndex++)
                        {
                            if (Main.lightPet[player.buffType[buffIndex]] && Main.lightPet[item.buffType])
                            {
                                useItem = false;
                            }
                            if (Main.vanityPet[player.buffType[buffIndex]] && Main.vanityPet[item.buffType])
                            {
                                useItem = false;
                            }
                        }
                    }

                    if (item.mana > 0 && useItem)
                    {
                        if (player.statMana >= (int)(item.mana * player.manaCost))
                        {
                            player.manaRegenDelay = (int)player.maxRegenDelay;
                            player.statMana      -= (int)(item.mana * player.manaCost);
                        }
                        else
                        {
                            useItem = false;
                        }
                    }

                    if (player.whoAmI == Main.myPlayer && item.type == 603 && !Main.cEd)
                    {
                        useItem = false;
                    }

                    if (buffType == 27)
                    {
                        buffType = Main.rand.Next(3);
                        if (buffType == 0)
                        {
                            buffType = 27;
                        }
                        if (buffType == 1)
                        {
                            buffType = 101;
                        }
                        if (buffType == 2)
                        {
                            buffType = 102;
                        }
                    }

                    if (useItem)
                    {
                        ItemLoader.UseItem(item, player);
                        sound = item.UseSound;
                        int buffTime = item.buffTime;
                        if (buffTime == 0)
                        {
                            buffTime = 3600;
                        }

                        player.AddBuff(buffType, buffTime);
                        if (item.consumable)
                        {
                            if (ItemLoader.ConsumeItem(item, player))
                            {
                                item.stack--;
                            }
                            if (item.stack <= 0)
                            {
                                item.TurnToAir();
                            }
                        }
                    }
                }
            }

            return(false);
        }
        public void QuickBuffFavoritedOnly()
        {
            if (this.player.noItems)
            {
                return;
            }
            LegacySoundStyle legacySoundStyle = null;

            for (int i = 0; i < 58; i++)
            {
                if (this.player.CountBuffs() == 22)
                {
                    return;
                }
                if (this.player.inventory[i].stack > 0 && this.player.inventory[i].type > 0 && this.player.inventory[i].favorited && this.player.inventory[i].buffType > 0 && !this.player.inventory[i].summon && this.player.inventory[i].buffType != 90)
                {
                    int  num2 = this.player.inventory[i].buffType;
                    bool flag = ItemLoader.CanUseItem(this.player.inventory[i], this.player);
                    for (int j = 0; j < 22; j++)
                    {
                        if (num2 == 27 && (this.player.buffType[j] == num2 || this.player.buffType[j] == 101 || this.player.buffType[j] == 102))
                        {
                            flag = false;
                            break;
                        }
                        if (this.player.buffType[j] == num2)
                        {
                            flag = false;
                            break;
                        }
                        if (Main.meleeBuff[num2] && Main.meleeBuff[this.player.buffType[j]])
                        {
                            flag = false;
                            break;
                        }
                    }
                    if (Main.lightPet[this.player.inventory[i].buffType] || Main.vanityPet[this.player.inventory[i].buffType])
                    {
                        for (int k = 0; k < 22; k++)
                        {
                            if (Main.lightPet[this.player.buffType[k]] && Main.lightPet[this.player.inventory[i].buffType])
                            {
                                flag = false;
                            }
                            if (Main.vanityPet[this.player.buffType[k]] && Main.vanityPet[this.player.inventory[i].buffType])
                            {
                                flag = false;
                            }
                        }
                    }
                    if (this.player.inventory[i].mana > 0 && flag)
                    {
                        if (this.player.statMana >= (int)((float)this.player.inventory[i].mana * this.player.manaCost))
                        {
                            float _maxRegenDelay = (1f - (float)this.player.statMana / (float)this.player.statManaMax2) * 60f * 4f + 45f;
                            _maxRegenDelay *= 0.7f;

                            this.player.manaRegenDelay = /*(int)this.player.*/ (int)_maxRegenDelay;
                            this.player.statMana      -= (int)((float)this.player.inventory[i].mana * this.player.manaCost);
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                    if (this.player.whoAmI == Main.myPlayer && this.player.inventory[i].type == 603 && !Main.cEd)
                    {
                        flag = false;
                    }
                    if (num2 == 27)
                    {
                        num2 = Main.rand.Next(3);
                        if (num2 == 0)
                        {
                            num2 = 27;
                        }
                        if (num2 == 1)
                        {
                            num2 = 101;
                        }
                        if (num2 == 2)
                        {
                            num2 = 102;
                        }
                    }
                    if (flag)
                    {
                        ItemLoader.UseItem(this.player.inventory[i], this.player);
                        legacySoundStyle = player.inventory[i].UseSound;
                        int num3 = this.player.inventory[i].buffTime;
                        if (num3 == 0)
                        {
                            num3 = 3600;
                        }
                        this.player.AddBuff(num2, num3, true);
                        if (this.player.inventory[i].consumable)
                        {
                            //bool consume = true;
                            //ItemLoader.ConsumeItem(this.player.inventory[i], this.player, ref consume);
                            bool consume = ItemLoader.ConsumeItem(this.player.inventory[i], this.player);
                            if (consume)
                            {
                                this.player.inventory[i].stack--;
                            }
                            if (this.player.inventory[i].stack <= 0)
                            {
                                this.player.inventory[i].TurnToAir();
                            }
                        }
                    }
                }
            }
            if (legacySoundStyle != null)
            {
                Main.PlaySound(legacySoundStyle, player.position);
                Recipe.FindRecipes();
            }
        }
Beispiel #29
0
        public override void AI()
        {
            Player  player = Main.player[projectile.owner];
            Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true);

            float chargeLevel2 = 20f;
            float chargeLevel3 = 60f;


            projectile.ai[0] += 1f;
            projectile.ai[1] += 1f;
            int num16 = 0;

            if (projectile.ai[0] >= chargeLevel2)
            {
                num16++;
            }

            if (projectile.ai[1] >= 10)
            {
                projectile.ai[1] = 0f;

                float   scaleFactor3 = player.inventory[player.selectedItem].shootSpeed * projectile.scale;
                Vector2 vector11     = vector;
                Vector2 value4       = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - vector11;
                if (player.gravDir == -1f)
                {
                    value4.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector11.Y;
                }
                Vector2 vector12 = Vector2.Normalize(value4);
                if (float.IsNaN(vector12.X) || float.IsNaN(vector12.Y))
                {
                    vector12 = -Vector2.UnitY;
                }
                vector12 *= scaleFactor3;
                if (vector12.X != projectile.velocity.X || vector12.Y != projectile.velocity.Y)
                {
                    projectile.netUpdate = true;
                }
                projectile.velocity = vector12;
            }
            if (projectile.soundDelay <= 0)
            {
                projectile.soundDelay  = 10 - num16;
                projectile.soundDelay *= 2;
                if (projectile.ai[0] != 1f)
                {
                    Main.PlaySound(SoundID.Item15, projectile.position);
                }
            }
            if (projectile.ai[0] > 10f)
            {
                Vector2 vector13 = Vector2.UnitX * 18f;
                vector13 = vector13.RotatedBy((double)(projectile.rotation - 1.57079637f), default(Vector2));
                Vector2 value5 = projectile.Center + vector13;
                for (int k = 0; k < num16 + 1; k++)
                {
                    float num19 = 0.4f;
                    if (k % 2 == 1)
                    {
                        num19 = 0.65f;
                    }
                    Vector2 vector14 = value5 + ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (12f - (float)(num16 * 2));
                    int     num20    = Dust.NewDust(vector14 - Vector2.One * 8f, 16, 16, 220, projectile.velocity.X / 2f, projectile.velocity.Y / 2f, 0, default(Color), 1f);
                    Main.dust[num20].velocity   = Vector2.Normalize(value5 - vector14) * 1.5f * (10f - (float)num16 * 2f) / 10f;
                    Main.dust[num20].noGravity  = true;
                    Main.dust[num20].scale      = num19;
                    Main.dust[num20].customData = player;
                }
            }
            if (Main.myPlayer == projectile.owner)
            {
                if ((player.channel && player.CheckMana(player.inventory[player.selectedItem].mana, true, false)) && !player.noItems && !player.CCed)
                {
                    if (projectile.ai[0] >= chargeLevel3)
                    {
                        Vector2 vector16 = Vector2.Normalize(projectile.velocity) * 10f;
                        if (float.IsNaN(vector16.X) || float.IsNaN(vector16.Y))
                        {
                            vector16 = -Vector2.UnitY;
                        }
                        int damage = (int)(projectile.damage * 5f);
                        Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vector16.X, vector16.Y, mod.ProjectileType("ChargeRifleFull"), damage, projectile.knockBack, projectile.owner, 0f, 0f);
                        Main.PlaySound(SoundID.Item92, projectile.position);
                        projectile.Kill();
                    }
                }
                else
                {
                    if (projectile.ai[0] < chargeLevel3)
                    {
                        Vector2 vector16 = Vector2.Normalize(projectile.velocity) * 10f;
                        if (float.IsNaN(vector16.X) || float.IsNaN(vector16.Y))
                        {
                            vector16 = -Vector2.UnitY;
                        }
                        int projType           = mod.ProjectileType("ChargeRifleHalf");
                        LegacySoundStyle sound = SoundID.Item11;
                        if (projectile.ai[0] < chargeLevel2)
                        {
                            projType = 14;
                            sound    = SoundID.Item11;
                        }
                        else
                        {
                            projType = mod.ProjectileType("ChargeRifleHalf");
                            sound    = SoundID.Item91;
                        }
                        int damage = (int)((projectile.damage - 38) + projectile.ai[0] * 2f);
                        Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vector16.X, vector16.Y, projType, damage, projectile.knockBack, projectile.owner, 0f, 0f);
                        Main.PlaySound(sound, projectile.position);
                    }
                    projectile.Kill();
                }
            }

            Vector2 thing = projectile.velocity;

            thing.Normalize(); // makes the value = 1
            thing *= 20f;
            Vector2 yAdd = new Vector2(0, 0);

            if (player.direction == 1)
            {
                yAdd.Y = 10;
            }
            projectile.position        = player.RotatedRelativePoint(player.MountedCenter, true) - projectile.Size / 2f + thing.RotatedBy((double)(MathHelper.Pi / 10), default(Vector2)) - yAdd;
            projectile.rotation        = projectile.velocity.ToRotation() + 1.57079637f;
            projectile.spriteDirection = projectile.direction;
            projectile.timeLeft        = 2;
            player.ChangeDir(projectile.direction);
            player.heldProj      = projectile.whoAmI;
            player.itemTime      = 2;
            player.itemAnimation = 2;
            player.itemRotation  = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction));

            float   scaleFactor = player.inventory[player.selectedItem].shootSpeed * projectile.scale;
            Vector2 vector3     = vector;
            Vector2 value2      = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - vector3;

            if (player.gravDir == -1f)
            {
                value2.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector3.Y;
            }
            Vector2 vector4 = Vector2.Normalize(value2);

            if (float.IsNaN(vector4.X) || float.IsNaN(vector4.Y))
            {
                vector4 = -Vector2.UnitY;
            }
            vector4 *= scaleFactor;
            if (vector4.X != projectile.velocity.X || vector4.Y != projectile.velocity.Y)
            {
                projectile.netUpdate = true;
            }
            projectile.velocity = vector4;
        }
 public override void ProcessTriggers(TriggersSet triggersSet)
 {
     if (AlchemistNPC.LampLight.JustPressed)
     {
         if (lamp == 0 && trigger)
         {
             trigger = false;
             lamp++;
             lf = true;
         }
         if (lamp == 1 && !trigger && !lf)
         {
             trigger = true;
             lamp    = 0;
         }
         lf = false;
     }
     if (AlchemistNPC.PipBoyTP.JustPressed && PB4K)
     {
         PipBoyTPMenu.visible = true;
     }
     if (DistantPotionsUse && PlayerInput.Triggers.Current.QuickBuff)
     {
         LegacySoundStyle type1 = (LegacySoundStyle)null;
         for (int index1 = 0; index1 < 40; ++index1)
         {
             if (player.CountBuffs() == 22)
             {
                 return;
             }
             if (player.bank.item[index1].stack > 0 && player.bank.item[index1].type > 0 && (player.bank.item[index1].buffType > 0 && !player.bank.item[index1].summon) && player.bank.item[index1].buffType != 90)
             {
                 int  type2 = player.bank.item[index1].buffType;
                 bool flag  = true;
                 for (int index2 = 0; index2 < 22; ++index2)
                 {
                     if (type2 == 27 && (player.buffType[index2] == type2 || player.buffType[index2] == 101 || player.buffType[index2] == 102))
                     {
                         flag = false;
                         break;
                     }
                     if (player.buffType[index2] == type2)
                     {
                         flag = false;
                         break;
                     }
                     if (Main.meleeBuff[type2] && Main.meleeBuff[player.buffType[index2]])
                     {
                         flag = false;
                         break;
                     }
                 }
                 if (Main.lightPet[player.bank.item[index1].buffType] || Main.vanityPet[player.bank.item[index1].buffType])
                 {
                     for (int index2 = 0; index2 < 22; ++index2)
                     {
                         if (Main.lightPet[player.buffType[index2]] && Main.lightPet[player.bank.item[index1].buffType])
                         {
                             flag = false;
                         }
                         if (Main.vanityPet[player.buffType[index2]] && Main.vanityPet[player.bank.item[index1].buffType])
                         {
                             flag = false;
                         }
                     }
                 }
                 if (player.bank.item[index1].mana > 0 & flag)
                 {
                     if (player.statMana >= (int)((double)player.bank.item[index1].mana * (double)player.manaCost))
                     {
                         player.manaRegenDelay = (int)player.maxRegenDelay;
                         player.statMana       = player.statMana - (int)((double)player.bank.item[index1].mana * (double)player.manaCost);
                     }
                     else
                     {
                         flag = false;
                     }
                 }
                 if (player.whoAmI == Main.myPlayer && player.bank.item[index1].type == 603 && !Main.cEd)
                 {
                     flag = false;
                 }
                 if (type2 == 27)
                 {
                     type2 = Main.rand.Next(3);
                     if (type2 == 0)
                     {
                         type2 = 27;
                     }
                     if (type2 == 1)
                     {
                         type2 = 101;
                     }
                     if (type2 == 2)
                     {
                         type2 = 102;
                     }
                 }
                 if (flag)
                 {
                     type1 = player.bank.item[index1].UseSound;
                     int time1 = player.bank.item[index1].buffTime;
                     if (time1 == 0)
                     {
                         time1 = 3600;
                     }
                     player.AddBuff(type2, time1, true);
                     if (player.bank.item[index1].consumable)
                     {
                         --player.bank.item[index1].stack;
                         if (player.bank.item[index1].stack <= 0)
                         {
                             player.bank.item[index1].TurnToAir();
                         }
                     }
                 }
             }
         }
         if (type1 == null)
         {
             return;
         }
         Main.PlaySound(type1, player.position);
         Recipe.FindRecipes();
     }
     if (AlchemistNPC.DiscordBuff.JustPressed)
     {
         if (Main.myPlayer == player.whoAmI && player.HasBuff(mod.BuffType("DiscordBuff")))
         {
             Vector2 vector2 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY);
             if (!Collision.SolidCollision(vector2, player.width, player.height))
             {
                 player.Teleport(vector2, 1, 0);
                 NetMessage.SendData(65, -1, -1, (NetworkText)null, 0, (float)player.whoAmI, (float)vector2.X, (float)vector2.Y, 1, 0, 0);
                 if (player.chaosState)
                 {
                     player.statLife = player.statLife - player.statLifeMax2 / 3;
                     PlayerDeathReason damageSource = PlayerDeathReason.ByOther(13);
                     if (Main.rand.Next(2) == 0)
                     {
                         damageSource = PlayerDeathReason.ByOther(player.Male ? 14 : 15);
                     }
                     if (player.statLife <= 0)
                     {
                         player.KillMe(damageSource, 1.0, 0, false);
                     }
                     player.lifeRegenCount = 0;
                     player.lifeRegenTime  = 0;
                 }
                 player.AddBuff(88, 600, true);
                 player.AddBuff(164, 60, true);
             }
         }
         if (Main.myPlayer == player.whoAmI && player.HasBuff(mod.BuffType("TrueDiscordBuff")))
         {
             Vector2 vector2 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY);
             if (!Collision.SolidCollision(vector2, player.width, player.height))
             {
                 player.Teleport(vector2, 1, 0);
                 NetMessage.SendData(65, -1, -1, (NetworkText)null, 0, (float)player.whoAmI, (float)vector2.X, (float)vector2.Y, 1, 0, 0);
                 if (player.chaosState)
                 {
                     player.statLife = player.statLife - player.statLifeMax2 / 7;
                     PlayerDeathReason damageSource = PlayerDeathReason.ByOther(13);
                     if (Main.rand.Next(2) == 0)
                     {
                         damageSource = PlayerDeathReason.ByOther(player.Male ? 14 : 15);
                     }
                     if (player.statLife <= 0)
                     {
                         player.KillMe(damageSource, 1.0, 0, false);
                     }
                     player.lifeRegenCount = 0;
                     player.lifeRegenTime  = 0;
                 }
                 player.AddBuff(88, 360, true);
             }
         }
     }
 }