Skip to content

Profile

Rijam edited this page Mar 26, 2024 · 1 revision

In vanilla, Town NPCs with hats have a hatless version of their textures for parties (they wear the party hats instead). All vanilla Town NPCs also have alternate textures for when they are shimmered. We can add alternate textures to our Town NPC with a Profile.

For this guide, we will be using these sprites:

In vanilla, the party textures just remove the hat that the Town NPC normally wears. Since our original sprites didn't have a hat, I added sunglasses instead.

TutorialTownNPC_Party TutorialTownNPC_Party TutorialTownNPC_Shimmer TutorialTownNPC_Shimmer TutorialTownNPC_Shimmer_Party TutorialTownNPC_Shimmer_Party TutorialTownNPC_Shimmer_Head TutorialTownNPC_Shimmer_Head

There are several parts to this. First, we want to add some properties and the Load() hook to our Town NPC.

private static int ShimmerHeadIndex;
private static Profiles.StackedNPCProfile NPCProfile;

public override void Load() {
	// Adds our Shimmer Head to the NPCHeadLoader.
	ShimmerHeadIndex = Mod.AddNPCHeadTexture(Type, Texture + "_Shimmer_Head");
}

Next, in SetStaticDefaults() we want to add:

NPCID.Sets.ShimmerTownTransform[Type] = true; // This set says that the Town NPC has a Shimmered form. Otherwise, the Town NPC will become transparent when touching Shimmer like other enemies.

// This creates a "profile" for our Town NPC, which allows for different textures during a party and/or while the NPC is shimmered.
NPCProfile = new Profiles.StackedNPCProfile(
	new Profiles.DefaultNPCProfile(Texture, NPCHeadLoader.GetHeadSlot(HeadTexture), Texture + "_Party"),
	new Profiles.DefaultNPCProfile(Texture + "_Shimmer", ShimmerHeadIndex, Texture + "_Shimmer_Party")
);

This will add our party, shimmer, shimmer party, and shimmer head icon textures. If you do not have extra party textures, remove the , Texture + "_Party" and , Texture + "_Shimmer_Party" parts.

Finally, we need to register this profile to our Town NPC by overring the TownNPCProfile() hook:

public override ITownNPCProfile TownNPCProfile() {
	return NPCProfile;
}

For a more customizable profile, see Advanced - ITownNPCProfile.



Clone this wiki locally