Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AddBuff()

void Terraria.NPC.AddBuff ( int type,
int time,
bool quiet = false )
inline

Definition at line 86746 of file NPC.cs.

86747 {
86748 if (buffImmune[type])
86749 {
86750 return;
86751 }
86752 if (!quiet)
86753 {
86754 if (Main.netMode == 1)
86755 {
86756 NetMessage.SendData(53, -1, -1, null, whoAmI, type, time);
86757 }
86758 else if (Main.netMode == 2)
86759 {
86760 NetMessage.SendData(54, -1, -1, null, whoAmI);
86761 }
86762 }
86763 int num = -1;
86764 for (int i = 0; i < maxBuffs; i++)
86765 {
86766 if (buffType[i] == type)
86767 {
86768 if (buffTime[i] < time)
86769 {
86770 buffTime[i] = time;
86771 }
86772 return;
86773 }
86774 }
86775 while (num == -1)
86776 {
86777 int num2 = -1;
86778 for (int j = 0; j < maxBuffs; j++)
86779 {
86780 if (!Main.debuff[buffType[j]])
86781 {
86782 num2 = j;
86783 break;
86784 }
86785 }
86786 if (num2 == -1)
86787 {
86788 return;
86789 }
86790 for (int k = num2; k < maxBuffs; k++)
86791 {
86792 if (buffType[k] == 0)
86793 {
86794 num = k;
86795 break;
86796 }
86797 }
86798 if (num == -1)
86799 {
86800 DelBuff(num2);
86801 }
86802 }
86803 buffType[num] = type;
86804 buffTime[num] = time;
86805 }
static readonly int maxBuffs
Definition NPC.cs:211
int[] buffTime
Definition NPC.cs:215
int type
Definition NPC.cs:445
void DelBuff(int buffIndex)
Definition NPC.cs:86824
bool[] buffImmune
Definition NPC.cs:217
int[] buffType
Definition NPC.cs:213

References Terraria.Main.debuff, Terraria.Main.netMode, Terraria.NetMessage.SendData(), and System.type.