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

◆ QuickBuff()

void Terraria.Player.QuickBuff ( )
inline

Definition at line 6086 of file Player.cs.

6087 {
6088 //IL_0259: Unknown result type (might be due to invalid IL or missing references)
6089 if (cursed || CCed || dead)
6090 {
6091 return;
6092 }
6094 if (CountBuffs() == maxBuffs)
6095 {
6096 return;
6097 }
6098 Item item = QuickBuff_PickBestFoodItem();
6099 if (item != null && ItemCheck_CheckCanUse(item))
6100 {
6101 legacySoundStyle = item.UseSound;
6102 int num = item.buffTime;
6103 if (num == 0)
6104 {
6105 num = 3600;
6106 }
6107 ItemLoader.UseItem(item, this);
6108 AddBuff(item.buffType, num);
6109 if (item.consumable && ItemLoader.ConsumeItem(item, this))
6110 {
6111 item.stack--;
6112 if (item.stack <= 0)
6113 {
6114 item.TurnToAir();
6115 }
6116 }
6117 }
6118 if (CountBuffs() != maxBuffs)
6119 {
6120 int num2 = 58;
6121 if (useVoidBag())
6122 {
6123 num2 = 98;
6124 }
6125 for (int i = 0; i < num2; i++)
6126 {
6127 Item item2 = ((i >= 58) ? bank4.item[i - 58] : inventory[i]);
6128 if (item2.stack <= 0 || item2.type <= 0 || item2.buffType <= 0 || item2.summon || !ItemCheck_CheckCanUse(item2))
6129 {
6130 continue;
6131 }
6132 int num3 = item2.buffType;
6134 if (item2.mana > 0 && flag)
6135 {
6137 {
6139 }
6140 else
6141 {
6142 flag = false;
6143 }
6144 }
6145 if (whoAmI == Main.myPlayer && item2.type == 603 && !Main.runningCollectorsEdition)
6146 {
6147 flag = false;
6148 }
6149 if (num3 == 27)
6150 {
6151 num3 = Main.rand.Next(3);
6152 if (num3 == 0)
6153 {
6154 num3 = 27;
6155 }
6156 if (num3 == 1)
6157 {
6158 num3 = 101;
6159 }
6160 if (num3 == 2)
6161 {
6162 num3 = 102;
6163 }
6164 }
6165 if (!flag)
6166 {
6167 continue;
6168 }
6169 ItemLoader.UseItem(item2, this);
6170 legacySoundStyle = item2.UseSound;
6171 int num4 = item2.buffTime;
6172 if (num4 == 0)
6173 {
6174 num4 = 3600;
6175 }
6176 AddBuff(num3, num4);
6177 if (item2.consumable && ItemLoader.ConsumeItem(item2, this))
6178 {
6179 item2.stack--;
6180 if (item2.stack <= 0)
6181 {
6182 item2.TurnToAir();
6183 }
6184 }
6185 if (CountBuffs() == maxBuffs)
6186 {
6187 break;
6188 }
6189 }
6190 }
6191 if (legacySoundStyle.HasValue)
6192 {
6194 Recipe.FindRecipes();
6195 }
6196 }
static SlotId PlaySound(in SoundStyle? style, Vector2? position=null, SoundUpdateCallback? updateCallback=null)
Attempts to play a sound style with the provided sound style (if it's not null), and returns a valid ...
Item[] item
The items this chest contains. F:Terraria.Chest.maxItems elements long.
Definition Chest.cs:93
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
static bool CanUseItem(Player player, Item item)
static bool ConsumeItem(Item item, Player player)
If ModItem.ConsumeItem or any of the GlobalItem.ConsumeItem hooks returns false, sets consume to fals...
static ? bool UseItem(Item item, Player player)
Returns false if any of ModItem.UseItem or GlobalItem.UseItem return false. Returns true if anything ...
This serves as the central class from which item-related functions are carried out....
Definition ItemLoader.cs:26
bool CheckMana(int amount, bool pay=false, bool blockQuickMana=false)
Definition Player.cs:57696
bool ItemCheck_CheckCanUse(Item sItem)
Definition Player.cs:52757
bool useVoidBag()
Definition Player.cs:21132
float manaRegenDelay
Definition Player.cs:2152
int CountBuffs()
Definition Player.cs:5908
float maxRegenDelay
Definition Player.cs:1602
Item QuickBuff_PickBestFoodItem()
Definition Player.cs:6198
void AddBuff(int type, int timeToAdd, bool quiet=true, bool foodHack=false)
Gives the player the provided buff. This accounts for if the player is immune to the buff....
Definition Player.cs:5700
static int maxBuffs
Definition Player.cs:3380
bool CCed
Checks if the player is currently "crowd controlled", meaning the player is F:Terraria....
Definition Player.cs:3716
Item[] inventory
The player's normal inventory. Indexes 0-9 hold the hotbar items, 10-49 the rest of the main inventor...
Definition Player.cs:1767
bool QuickBuff_ShouldBotherUsingThisBuff(int attemptedType)
Definition Player.cs:6256
This data type describes in detail how a sound should be played. Passable to the M:Terraria....
Definition SoundStyle.cs:19

References Terraria.Player.AddBuff(), Terraria.Player.bank4, Terraria.Item.buffTime, Terraria.Item.buffType, Terraria.ModLoader.CombinedHooks.CanUseItem(), Terraria.Player.CCed, Terraria.Player.CheckMana(), Terraria.Item.consumable, Terraria.ModLoader.ItemLoader.ConsumeItem(), Terraria.Player.CountBuffs(), Terraria.Player.cursed, Terraria.Player.dead, Terraria.Recipe.FindRecipes(), Terraria.Player.inventory, Terraria.Chest.item, Terraria.Player.ItemCheck_CheckCanUse(), Terraria.Player.manaRegenDelay, Terraria.Player.maxBuffs, Terraria.Player.maxRegenDelay, Terraria.Main.myPlayer, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.Player.QuickBuff_PickBestFoodItem(), Terraria.Player.QuickBuff_ShouldBotherUsingThisBuff(), Terraria.Main.rand, Terraria.Main.runningCollectorsEdition, Terraria.Item.stack, Terraria.Item.TurnToAir(), Terraria.ModLoader.ItemLoader.UseItem(), Terraria.Item.UseSound, Terraria.Player.useVoidBag(), and Terraria.Entity.whoAmI.

Referenced by Terraria.Player.Update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: