Attempts to apply a prefix to this T:Terraria.Item.
- Parameters
-
| prefixWeWant |
If prefixWeWant == 0, do nothing.
If prefixWeWant == -1, then a random prefix is rolled, with a 25% chance to not roll a prefix and an additional 66% chance to void any prefixes in the F:Terraria.ID.PrefixID.Sets.ReducedNaturalChance set. This is used for chest loot, starting equipment, etc.
If prefixWeWant == -2, then a random prefix is rolled, with no chance to not roll a prefix. This is used for the Goblin Tinkerer.
If prefixWeWant == -3, then this method simple checks if this item can receive prefixes.
Otherwise, attempt to apply the given T:Terraria.ID.PrefixID to this item. |
- Returns
false if:
-
prefixWeWant is
0
-
M:Terraria.Item.CanHavePrefixes returns
false
-
M:Terraria.Item.CanApplyPrefix(System.Int32) returns
false
-
prefixWeWant == -1 and F:Terraria.Item.maxStack > 1
-
M:Terraria.ModLoader.ItemLoader.PrefixChance(Terraria.Item,System.Int32,Terraria.Utilities.UnifiedRandom) returns
false
-
prefixWeWant == -1 or -2 or -3 and M:Terraria.ModLoader.PrefixLoader.Roll(Terraria.Item,Terraria.Utilities.UnifiedRandom,System.Int32@,System.Boolean) returns false.
Otherwise, return true.
Definition at line 1279 of file Item.cs.
1280 {
1281 if (!
WorldGen.gen && Main.rand ==
null)
1282 {
1284 }
1286 {
1287 return false;
1288 }
1290 {
1291 return false;
1292 }
1294 {
1295 return false;
1296 }
1298 {
1299 return false;
1300 }
1304 {
1305 return false;
1306 }
1317 {
1320 {
1321 return true;
1322 }
1324 {
1326 }
1329 {
1331 }
1333 {
1334 return false;
1335 }
1337 {
1338 case -3:
1339 return true;
1340 case -1:
1342 {
1343 return true;
1344 }
1345 break;
1346 }
1348 {
1351 }
1353 {
1356 }
1357 }
1369 {
1371 }
1375 {
1377 }
1379 {
1381 }
1383 {
1385 }
1387 {
1389 }
1391 {
1393 }
1395 if ((
double)
num >= 1.2)
1396 {
1398 }
1399 else if ((
double)
num >= 1.05)
1400 {
1402 }
1403 else if ((
double)
num <= 0.8)
1404 {
1406 }
1407 else if ((
double)
num <= 0.95)
1408 {
1410 }
1412 {
1414 }
1416 {
1418 }
1420 {
1422 {
1424 }
1426 {
1427 rare = RarityLoader.RarityCount - 1;
1428 }
1429 }
1433 return true;
1434 }
static bool[] ReducedNaturalChance
If true for a given prefix type (F:Terraria.Item.prefix), then that prefix has a 66% to not be applie...
static readonly int Count
float knockBack
The force of the knock back. Max value is 20. The Knockback wiki pagehas info on existing values....
int useAnimation
The time span of the using animation for the item in ticks. This is independent of the time it takes ...
int crit
The base critical chance for this item. Remember that the player has a base crit chance of 4....
int value
The number of copper coins this item is worth (aka, cost to buy from a merchant). Setting it to 10462...
bool TryGetPrefixStatMultipliersForItem(int rolledPrefix, out float dmg, out float kb, out float spd, out float size, out float shtspd, out float mcst, out int crt)
int reuseDelay
A delay in frames added at the end of the using animation for the item, during which the player wont ...
int rare
Indicates the rarity of an item. Assign to a T:Terraria.ID.ItemRarityID value. Vanilla values range f...
int maxStack
The maximum number of items that can be contained within a single stack. F:Terraria....
float scale
The size multiplier of the item's sprite while the item is being used. Also increases range for melee...
int damage
The base damage inflicted by this item. The List of weapons wiki pagecan be a useful guide for decidi...
void UndoItemAnimationCompensations()
float shootSpeed
The velocity in pixels the projectile fired by this item will have. Actual velocity depends on the pr...
int mana
The amount of mana this item consumes on use. Use M:Terraria.ModLoader.ModItem.ModifyManaCost(Terra...
bool CanHavePrefixes()
Determines if this T:Terraria.Item can receive prefixes.
int useTime
The time span of using the item in ticks. This is independent of the time it takes for the item anima...
void ApplyItemAnimationCompensationsToVanillaItems()
int prefix
The current prefix applied to this item. Either a T:Terraria.ID.PrefixID entry or M:Terraria....
bool RollAPrefix(UnifiedRandom random, ref int rolledPrefix)
bool CanApplyPrefix(int prefix)
Determines if this T:Terraria.Item can receive the given prefix.
static ? bool PrefixChance(Item item, int pre, UnifiedRandom rand)
Allows for blocking, forcing and altering chance of prefix rolling. False (block) takes precedence ov...
This serves as the central class from which item-related functions are carried out....
static ModPrefix GetPrefix(int type)
Returns the ModPrefix associated with specified type If not a ModPrefix, returns null.
static bool Roll(Item item, UnifiedRandom unifiedRandom, out int prefix, bool justCheck)
static ModRarity GetRarity(int type)
References Terraria.Item.ApplyItemAnimationCompensationsToVanillaItems(), Terraria.Item.CanApplyPrefix(), Terraria.Item.CanHavePrefixes(), Terraria.ID.PrefixID.Count, Terraria.Item.crit, Terraria.Item.damage, Terraria.WorldGen.gen, Terraria.ModLoader.PrefixLoader.GetPrefix(), Terraria.ModLoader.RarityLoader.GetRarity(), Terraria.Item.knockBack, Terraria.Item.mana, Terraria.Item.maxStack, Terraria.Item.prefix, Terraria.ModLoader.ItemLoader.PrefixChance(), Terraria.Main.rand, Terraria.Item.rare, Terraria.ModLoader.RarityLoader.RarityCount, Terraria.ID.PrefixID.Sets.ReducedNaturalChance, Terraria.Item.reuseDelay, Terraria.ModLoader.PrefixLoader.Roll(), Terraria.Item.RollAPrefix(), Terraria.Item.scale, Terraria.Item.shootSpeed, Terraria.Item.TryGetPrefixStatMultipliersForItem(), Terraria.Item.UndoItemAnimationCompensations(), Terraria.Item.useAnimation, Terraria.Item.useTime, and Terraria.Item.value.
Referenced by Terraria.Item.Item(), Terraria.WorldGen.AddBuriedChest(), Terraria.Item.DeserializeFrom(), Terraria.GameContent.Drawing.TileDrawing.DrawSpecialTilesLegacy(), Terraria.Player.DropItems_GetDefaults(), Terraria.ModLoader.TileLoader.GetItemDrops(), Terraria.WorldGen.KillTile(), Terraria.ModLoader.IO.ItemIO.Load(), Terraria.IO.WorldFile.LoadChests(), Terraria.Item.NewItem_Inner(), Terraria.UI.ItemSlot.OverrideHover(), Terraria.GameContent.UI.Chat.ItemTagHandler.Parse(), Terraria.WorldGen.PrefixItemFromOptions(), Terraria.GameContent.Tile_Entities.TEDisplayDoll.ReadExtraData(), Terraria.GameContent.Tile_Entities.TEFoodPlatter.ReadExtraData(), Terraria.GameContent.Tile_Entities.TEHatRack.ReadExtraData(), Terraria.GameContent.Tile_Entities.TEItemFrame.ReadExtraData(), Terraria.GameContent.Tile_Entities.TEWeaponsRack.ReadExtraData(), Terraria.GameContent.Tile_Entities.TEDisplayDoll.ReadItem(), Terraria.GameContent.Tile_Entities.TEHatRack.ReadItem(), and Terraria.ModLoader.IO.ItemIO.Receive().