Terraria.Player.AddBuff C# (CSharp) Method

AddBuff() public method

public AddBuff ( int type, int time1, bool quiet = true ) : void
type int
time1 int
quiet bool
return void
        public void AddBuff(int type, int time1, bool quiet = true)
        {
            if (this.buffImmune[type])
                return;
            int num = time1;
            if (Main.expertMode && this.whoAmI == Main.myPlayer && (type == 20 || type == 22 || (type == 23 || type == 24) || (type == 30 || type == 31 || (type == 32 || type == 33)) || (type == 35 || type == 36 || (type == 39 || type == 44) || (type == 46 || type == 47 || (type == 69 || type == 70))) || type == 80))
                num = (int)((double)Main.expertDebuffTime * (double)num);
            if (!quiet && Main.netMode == 1)
            {
                bool flag = true;
                for (int index = 0; index < 22; ++index)
                {
                    if (this.buffType[index] == type)
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                    NetMessage.SendData(55, -1, -1, "", this.whoAmI, (float)type, (float)num, 0.0f, 0, 0, 0);
            }
            int index1 = -1;
            for (int index2 = 0; index2 < 22; ++index2)
            {
                if (this.buffType[index2] == type)
                {
                    if (type == 94)
                    {
                        this.buffTime[index2] += num;
                        if (this.buffTime[index2] <= Player.manaSickTimeMax)
                            return;
                        this.buffTime[index2] = Player.manaSickTimeMax;
                        return;
                    }
                    if (this.buffTime[index2] >= num)
                        return;
                    this.buffTime[index2] = num;
                    return;
                }
            }
            if (Main.vanityPet[type] || Main.lightPet[type])
            {
                for (int b = 0; b < 22; ++b)
                {
                    if (Main.vanityPet[type] && Main.vanityPet[this.buffType[b]])
                        this.DelBuff(b);
                    if (Main.lightPet[type] && Main.lightPet[this.buffType[b]])
                        this.DelBuff(b);
                }
            }
            while (index1 == -1)
            {
                int b = -1;
                for (int index2 = 0; index2 < 22; ++index2)
                {
                    if (!Main.debuff[this.buffType[index2]])
                    {
                        b = index2;
                        break;
                    }
                }
                if (b == -1)
                    return;
                for (int index2 = b; index2 < 22; ++index2)
                {
                    if (this.buffType[index2] == 0)
                    {
                        index1 = index2;
                        break;
                    }
                }
                if (index1 == -1)
                    this.DelBuff(b);
            }
            this.buffType[index1] = type;
            this.buffTime[index1] = num;
            if (!Main.meleeBuff[type])
                return;
            for (int b = 0; b < 22; ++b)
            {
                if (b != index1 && Main.meleeBuff[this.buffType[b]])
                    this.DelBuff(b);
            }
        }

Usage Example

Example #1
5
        public override bool UseItem(Player player)
        {
            if (player.altFunctionUse == 2)
            {
                if (player.HasBuff(mod.BuffType("UnPowered")) >= 0)
                {

                }
                else
                {
                    player.AddBuff(mod.BuffType("PowerUnleash"), 1800);
                    player.AddBuff(mod.BuffType("UnPowered"), 7200);
                }
            }

            return true;
        }
All Usage Examples Of Terraria.Player::AddBuff
Player