コード例 #1
0
ファイル: BulletSlime.cs プロジェクト: Muzuwi/AmmoboxPlus
        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            if (AmmoboxPlus.isEnemyBlacklisted(target.type))
            {
                return;
            }
            target.GetGlobalNPC <AmmoboxGlobalNPC>().apSlime = true;

            if (Main.netMode == 0)
            {
                target.AddBuff(ModContent.BuffType <Buffs.Slime>(), 200);
                target.AddBuff(BuffID.Slimed, 200);
            }
            else
            {
                target.AddBuff(BuffID.Slimed, 200);
                var packet   = mod.GetPacket();
                int buffType = ModContent.BuffType <Buffs.Slime>();
                packet.Write((byte)AmmoboxMsgType.AmmoboxSlime);
                packet.Write(target.whoAmI);
                packet.Write(buffType);
                packet.Write(200);
                packet.Send();
            }
        }
コード例 #2
0
        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            //  Check if enemy is in water
            //  Horrible way to actually do it, might not get all edge cases
            int posXlow = (int)target.position.X / 16;
            int posYlow = (int)target.position.Y / 16;
            int posXhi  = ((int)target.position.X + target.width) / 16;
            int posYhi  = ((int)target.position.Y + target.height) / 16;

            if (AmmoboxPlus.isEnemyBlacklisted(target.type))
            {
                return;
            }


            //  Have we reached Stuck limit?
            if (target.GetGlobalNPC <AmmoboxGlobalNPC>().apStuckLimit)
            {
                //  If we have more parts in the chain, apply to the rest
                if (target.realLife != -1)
                {
                    Main.npc[target.realLife].AddBuff(ModContent.BuffType <Buffs.Cold>(), 500);
                    int index = 0;
                    foreach (NPC n in Main.npc)
                    {
                        if (n.realLife == target.realLife)
                        {
                            Main.npc[index].AddBuff(ModContent.BuffType <Buffs.Cold>(), 500);
                        }
                        ++index;
                    }
                }
                else
                {
                    target.AddBuff(ModContent.BuffType <Buffs.Cold>(), 500);
                }
            }
            else     //  No stuck limit

            //  If enemy is in water, apply higher chance
            {
                if (Main.tile[posXlow, posYlow].liquid > 0 || Main.tile[posXhi, posYhi].liquid > 0)
                {
                    if (WorldGen.genRand.Next(50) == 0)
                    {
                        processAddBuffIce(ref target, ModContent.BuffType <Buffs.Stuck>(), 300);
                    }
                }
                else
                {
                    if (WorldGen.genRand.Next(100) == 0)
                    {
                        processAddBuffIce(ref target, ModContent.BuffType <Buffs.Stuck>(), 300);
                    }
                }

                //  If multi-part enemy
                if (target.realLife != -1)
                {
                    Main.npc[target.realLife].AddBuff(ModContent.BuffType <Buffs.Cold>(), 500);
                    int index = 0;
                    foreach (NPC n in Main.npc)
                    {
                        if (n.realLife == target.realLife)
                        {
                            Main.npc[index].AddBuff(ModContent.BuffType <Buffs.Cold>(), 500);
                        }
                        ++index;
                    }
                }
                else
                {
                    target.AddBuff(ModContent.BuffType <Buffs.Cold>(), 500);
                }
            }
        }