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

◆ SetDefaults() [1/2]

void Terraria.Item.SetDefaults ( int Type,
bool noMatCheck = false,
ItemVariant variant = null )
inline

Definition at line 47337 of file Item.cs.

47338 {
47339 if (Type < 0)
47340 {
47342 return;
47343 }
47344 if (Main.netMode == 1 || Main.netMode == 2)
47345 {
47347 }
47348 else
47349 {
47350 playerIndexTheItemIsReservedFor = Main.myPlayer;
47351 }
47353 if (type >= ItemID.Count)
47354 {
47355 type = 0;
47356 }
47357 if (variant == null)
47358 {
47360 }
47361 else if (!ItemVariants.HasVariant(Type, variant))
47362 {
47363 variant = null;
47364 }
47365 Variant = variant;
47366 if (type == 0)
47367 {
47368 netID = 0;
47369 stack = 0;
47370 }
47371 else if (ItemID.Sets.IsFood[type])
47372 {
47374 }
47375 else if (type <= 1000)
47376 {
47378 }
47379 else if (type <= 2001)
47380 {
47382 }
47383 else if (type <= 3000)
47384 {
47386 }
47387 else if (type <= 3989)
47388 {
47390 }
47391 else
47392 {
47394 }
47395 dye = (byte)GameShaders.Armor.GetShaderIdFromItemId(type);
47396 if (hairDye != 0)
47397 {
47398 hairDye = GameShaders.Hair.GetShaderIdFromItemId(type);
47399 }
47400 if (type == 2015)
47401 {
47402 value = sellPrice(0, 0, 5);
47403 }
47404 if (type == 2016)
47405 {
47406 value = sellPrice(0, 0, 7, 50);
47407 }
47408 if (type == 2017)
47409 {
47410 value = sellPrice(0, 0, 7, 50);
47411 }
47412 if (type == 5212)
47413 {
47414 value = sellPrice(0, 0, 7, 50);
47415 }
47416 if (type == 5300)
47417 {
47418 value = sellPrice(0, 0, 7, 50);
47419 }
47420 if (type == 5311)
47421 {
47422 value = sellPrice(0, 0, 7, 50);
47423 }
47424 if (type == 5312)
47425 {
47426 value = sellPrice(0, 0, 7, 50);
47427 }
47428 if (type == 5313)
47429 {
47430 value = sellPrice(0, 0, 7, 50);
47431 }
47432 if (type == 2019)
47433 {
47434 value = sellPrice(0, 0, 5);
47435 }
47436 if (type == 2018)
47437 {
47438 value = sellPrice(0, 0, 5);
47439 }
47440 if (type == 3563)
47441 {
47442 value = sellPrice(0, 0, 5);
47443 }
47444 if (type == 261)
47445 {
47446 value = sellPrice(0, 0, 7, 50);
47447 }
47448 if (type == 2205)
47449 {
47450 value = sellPrice(0, 0, 12, 50);
47451 }
47452 if (type == 2123)
47453 {
47454 value = sellPrice(0, 0, 7, 50);
47455 }
47456 if (type == 2122)
47457 {
47458 value = sellPrice(0, 0, 7, 50);
47459 }
47460 if (type == 2003)
47461 {
47462 value = sellPrice(0, 0, 10);
47463 }
47464 if (type == 2156)
47465 {
47466 value = sellPrice(0, 0, 15);
47467 }
47468 if (type == 2157)
47469 {
47470 value = sellPrice(0, 0, 15);
47471 }
47472 if (type == 2121)
47473 {
47474 value = sellPrice(0, 0, 10);
47475 }
47476 if (type == 1992)
47477 {
47478 value = sellPrice(0, 0, 3);
47479 }
47480 if (type == 2004)
47481 {
47482 value = sellPrice(0, 0, 5);
47483 }
47484 if (type == 2002)
47485 {
47486 value = sellPrice(0, 0, 5);
47487 }
47488 if (type == 2740)
47489 {
47490 value = sellPrice(0, 0, 2, 50);
47491 }
47492 if (type == 2006)
47493 {
47494 value = sellPrice(0, 0, 10);
47495 }
47496 if (type == 3191)
47497 {
47498 value = sellPrice(0, 0, 20);
47499 }
47500 if (type == 3192)
47501 {
47502 value = sellPrice(0, 0, 2, 50);
47503 }
47504 if (type == 3193)
47505 {
47506 value = sellPrice(0, 0, 5);
47507 }
47508 if (type == 3194)
47509 {
47510 value = sellPrice(0, 0, 10);
47511 }
47512 if (type == 2007)
47513 {
47514 value = sellPrice(0, 0, 50);
47515 }
47516 if (type == 2673)
47517 {
47518 value = sellPrice(0, 10);
47519 }
47520 if (bait > 0)
47521 {
47522 if (bait >= 50)
47523 {
47524 rare = 3;
47525 }
47526 else if (bait >= 30)
47527 {
47528 rare = 2;
47529 }
47530 else if (bait >= 15)
47531 {
47532 rare = 1;
47533 }
47534 }
47535 if (type >= 1994 && type <= 2001)
47536 {
47537 int num = type - 1994;
47538 if (num == 0)
47539 {
47540 value = sellPrice(0, 0, 5);
47541 }
47542 if (num == 4)
47543 {
47544 value = sellPrice(0, 0, 10);
47545 }
47546 if (num == 6)
47547 {
47548 value = sellPrice(0, 0, 15);
47549 }
47550 if (num == 3)
47551 {
47552 value = sellPrice(0, 0, 20);
47553 }
47554 if (num == 7)
47555 {
47556 value = sellPrice(0, 0, 30);
47557 }
47558 if (num == 2)
47559 {
47560 value = sellPrice(0, 0, 40);
47561 }
47562 if (num == 1)
47563 {
47564 value = sellPrice(0, 0, 75);
47565 }
47566 if (num == 5)
47567 {
47568 value = sellPrice(0, 1);
47569 }
47570 }
47571 if (type == 2663 || type == 1720 || type == 2137 || type == 2155 || type == 2151 || type == 1704 || type == 2143 || type == 1710 || type == 2238 || type == 2133 || type == 2147 || type == 2405 || type == 1716 || type == 1705)
47572 {
47573 value = sellPrice(0, 2);
47574 }
47575 if (Main.projHook[shoot])
47576 {
47577 useStyle = 0;
47578 useTime = 0;
47579 useAnimation = 0;
47580 }
47581 if (ItemID.Sets.IsDrill[type] || ItemID.Sets.IsChainsaw[type] || type == 1262)
47582 {
47583 useTime = (int)((double)useTime * 0.6);
47584 if (useTime < 1)
47585 {
47586 useTime = 1;
47587 }
47588 useAnimation = (int)((double)useAnimation * 0.6);
47589 if (useAnimation < 1)
47590 {
47591 useAnimation = 1;
47592 }
47593 tileBoost--;
47594 }
47595 if (ItemID.Sets.IsFood[type])
47596 {
47597 holdStyle = 1;
47598 }
47599 if (type >= 1803 && type <= 1807)
47600 {
47601 SetDefaults(1533 + type - 1803);
47602 }
47603 if (dye > 0)
47604 {
47606 }
47607 if (createTile == 19)
47608 {
47610 }
47611 netID = type;
47612 if (!noMatCheck)
47613 {
47615 }
47617 if (type > 0 && type < ItemID.Count && ItemID.Sets.Deprecated[type])
47618 {
47619 netID = 0;
47620 type = 0;
47621 stack = 0;
47622 }
47623 }
static ItemVariant SelectVariant(int itemId)
static bool HasVariant(int itemId, ItemVariant variant)
static HairShaderDataSet Hair
Definition GameShaders.cs:9
static ArmorShaderDataSet Armor
Definition GameShaders.cs:7
static bool[] IsAMaterial
Definition ItemID.cs:211
static bool[] Deprecated
Definition ItemID.cs:1042
static bool[] IsChainsaw
Definition ItemID.cs:227
static bool[] IsFood
Definition ItemID.cs:233
static bool[] IsDrill
Definition ItemID.cs:225
static readonly short Count
Definition ItemID.cs:12138
void RebuildTooltip()
Definition Item.cs:1019
int useAnimation
Definition Item.cs:145
void SetDefaults2(int type)
Definition Item.cs:14581
bool material
Definition Item.cs:267
void SetDefaults3(int type)
Definition Item.cs:23496
void netDefaults(int type)
Definition Item.cs:1088
void ResetStats(int Type)
Definition Item.cs:47633
int value
Definition Item.cs:259
int stack
Definition Item.cs:149
int shoot
Definition Item.cs:235
int maxStack
Definition Item.cs:151
int createTile
Definition Item.cs:161
int useStyle
Definition Item.cs:139
static int sellPrice(int platinum=0, int gold=0, int silver=0, int copper=0)
Definition Item.cs:47984
static int CommonMaxStack
Definition Item.cs:57
void SetFoodDefaults(int type)
Definition Item.cs:46739
int tileBoost
Definition Item.cs:159
int playerIndexTheItemIsReservedFor
Definition Item.cs:231
int netID
Definition Item.cs:291
int holdStyle
Definition Item.cs:137
int useTime
Definition Item.cs:147
void SetDefaults4(int type)
Definition Item.cs:30273
void SetDefaults(int Type=0)
Definition Item.cs:47332
void SetDefaults5(int type)
Definition Item.cs:38529
short hairDye
Definition Item.cs:117
void SetDefaults1(int type)
Definition Item.cs:2350
int bait
Definition Item.cs:99
byte dye
Definition Item.cs:95

References Terraria.Graphics.Shaders.GameShaders.Armor, Terraria.Item.bait, Terraria.Item.CommonMaxStack, Terraria.ID.ItemID.Count, Terraria.Item.createTile, Terraria.ID.ItemID.Sets.Deprecated, Terraria.Item.dye, Terraria.Graphics.Shaders.GameShaders.Hair, Terraria.Item.hairDye, Terraria.GameContent.Items.ItemVariants.HasVariant(), Terraria.Item.holdStyle, Terraria.ID.ItemID.Sets.IsAMaterial, Terraria.ID.ItemID.Sets.IsChainsaw, Terraria.ID.ItemID.Sets.IsDrill, Terraria.ID.ItemID.Sets.IsFood, Terraria.Item.material, Terraria.Item.maxStack, Terraria.Main.myPlayer, Terraria.Item.netDefaults(), Terraria.Item.netID, Terraria.Main.netMode, Terraria.Item.playerIndexTheItemIsReservedFor, Terraria.Main.projHook, Terraria.Item.rare, Terraria.Item.RebuildTooltip(), Terraria.Item.ResetStats(), Terraria.GameContent.Items.ItemVariants.SelectVariant(), Terraria.Item.sellPrice(), Terraria.Item.SetDefaults(), Terraria.Item.SetDefaults1(), Terraria.Item.SetDefaults2(), Terraria.Item.SetDefaults3(), Terraria.Item.SetDefaults4(), Terraria.Item.SetDefaults5(), Terraria.Item.SetFoodDefaults(), Terraria.Item.shoot, Terraria.Item.stack, Terraria.Item.tileBoost, Terraria.Item.type, Terraria.Item.useAnimation, Terraria.Item.useStyle, Terraria.Item.useTime, and Terraria.Item.value.