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

◆ AI_061_FishingBobber_GiveItemToPlayer()

void Terraria.Projectile.AI_061_FishingBobber_GiveItemToPlayer ( Player thePlayer,
int itemType )
inlineprivate

Definition at line 57283 of file Projectile.cs.

57284 {
57285 //IL_01f0: Unknown result type (might be due to invalid IL or missing references)
57286 //IL_0210: Unknown result type (might be due to invalid IL or missing references)
57287 Item item = new Item();
57288 item.SetDefaults(itemType);
57289 if (itemType == 3196)
57290 {
57291 int finalFishingLevel = thePlayer.GetFishingConditions().FinalFishingLevel;
57292 int minValue = (finalFishingLevel / 20 + 3) / 2;
57293 int num = (finalFishingLevel / 10 + 6) / 2;
57294 if (Main.rand.Next(50) < finalFishingLevel)
57295 {
57296 num++;
57297 }
57298 if (Main.rand.Next(100) < finalFishingLevel)
57299 {
57300 num++;
57301 }
57302 if (Main.rand.Next(150) < finalFishingLevel)
57303 {
57304 num++;
57305 }
57306 if (Main.rand.Next(200) < finalFishingLevel)
57307 {
57308 num++;
57309 }
57310 int stack = Main.rand.Next(minValue, num + 1);
57311 item.stack = stack;
57312 }
57313 if (itemType == 3197)
57314 {
57315 int finalFishingLevel2 = thePlayer.GetFishingConditions().FinalFishingLevel;
57316 int minValue2 = (finalFishingLevel2 / 4 + 15) / 2;
57317 int num2 = (finalFishingLevel2 / 2 + 40) / 2;
57318 if (Main.rand.Next(50) < finalFishingLevel2)
57319 {
57320 num2 += 6;
57321 }
57322 if (Main.rand.Next(100) < finalFishingLevel2)
57323 {
57324 num2 += 6;
57325 }
57326 if (Main.rand.Next(150) < finalFishingLevel2)
57327 {
57328 num2 += 6;
57329 }
57330 if (Main.rand.Next(200) < finalFishingLevel2)
57331 {
57332 num2 += 6;
57333 }
57334 int stack2 = Main.rand.Next(minValue2, num2 + 1);
57335 item.stack = stack2;
57336 }
57339 item.newAndShiny = true;
57340 Item item2 = thePlayer.GetItem(owner, item, default(GetItemSettings));
57341 if (item2.stack > 0)
57342 {
57343 int number = Item.NewItem(new EntitySource_OverfullInventory(thePlayer), (int)position.X, (int)position.Y, width, height, itemType, item2.stack, noBroadcast: false, 0, noGrabDelay: true);
57344 if (Main.netMode == 1)
57345 {
57346 NetMessage.SendData(21, -1, -1, null, number, 1f);
57347 }
57348 }
57349 else
57350 {
57351 item.position.X = base.Center.X - (float)(item.width / 2);
57352 item.position.Y = base.Center.Y - (float)(item.height / 2);
57353 item.active = true;
57354 PopupText.NewText(PopupTextContext.RegularItemPickup, item, 0);
57355 }
57356 }
Used when attempting to add an item to the player's inventory, but it cannot fit so it spawns in the ...
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
static void CaughtFishStack(Item item)
This serves as the central class from which item-related functions are carried out....
Definition ItemLoader.cs:26
static void ModifyCaughtFish(Player player, Item fish)
This is where all ModPlayer hooks are gathered and called.
int owner
The index of the player who owns this projectile. In Multiplayer, Clients "own" projectiles that they...

References Terraria.ModLoader.ItemLoader.CaughtFishStack(), Terraria.Entity.height, Terraria.ModLoader.PlayerLoader.ModifyCaughtFish(), Terraria.Main.netMode, Terraria.Item.NewItem(), Terraria.PopupText.NewText(), Terraria.Main.rand, Terraria.NetMessage.SendData(), Terraria.Item.SetDefaults(), and Terraria.Entity.width.

+ Here is the call graph for this function: