[1.4 Alpha] Bestiary Stars - mikrono/tModLoaderWiki_kr_ko GitHub Wiki
The stars, or "rating", in the ingame Bestiary are controlled by a multitude of factors.
Below is the general formula (found in Terraria.ID.ContentSamples.GetNPCBestiaryRarityStarsCount()) that the game uses to determine the stars for any given npc, with a few exceptions:
- Start with a default stars rating of
1. - Add
npc.rarityto the rating. - Check the following conditions in order, adding to the rating only once:
- Is
npc.rarity == 1true? If so, add1to the rating. - Is
npc.rarity == 2true? If so, add1.5to the rating. - Is
npc.rarity == 3true? If so, add2to the rating. - Is
npc.rarity == 4true? If so, add2.5to the rating. - Is
npc.rarity == 5true? If so, add3to the rating. - Is
npc.rarity > 0true? If so, add3.5to the rating. (This condition is true for any rarities above5)
- Is
- Is
npc.bosstrue? If so, add0.5to the rating. - Calculate the sum of
npc.damage + npc.defense + npc.lifeMax / 4. The stats used here are the NPC's stats in Normal Mode. - Using that sum, check the following conditions in order, adding to the rating only once:
- Is the sum greater than
10000? If so, add3.5to the rating. - Is the sum greater than
5000? If so, add3to the rating. - Is the sum greater than
1000? If so, add2.5to the rating. - Is the sum greater than
500? If so, add2to the rating. - Is the sum greater than
150? If so, add1.5to the rating. - Is the sum greater than
50? If so, add1to the rating.
- Is the sum greater than
- Cap the rating to
5, truncate it and then return it.
How can I add a custom stars rating to my NPC?
The dictionary ContentSamples.NpcBestiaryRarityStars stores the stars rating for all NPCs, including modded ones.
To manually set the rating for an NPC, set ContentSamples.NpcBestiaryRarityStars[type] = stars; in GlobalNPC.SetBestiary().
Example:
public override void SetBestiary(NPC npc, BestiaryDatabase database, BestiaryEntry bestiaryEntry){
//Sets the rarity of ExamplePerson to 5 stars
ContentSamples.NpcBestiaryRarityStars[ModContent.NPCType<ExamplePerson>()] = 5;
}
Setting an NPC's rating to less than 0 is treated as if the NPC's rating were 0.
Setting an NPC's rating to more than 5 is treated as if the NPC's rating were 5.