JavidPack / ModdersToolkit

A mod for modders to use for modding.
https://forums.terraria.org/index.php?threads/modders-toolkit-a-mod-for-modders-doing-modding.55738/
18 stars 6 forks source link

NPCLoader.SpawnNPC inconsistency with npc spawn tool #31

Open JavidPack opened 1 year ago

JavidPack commented 1 year ago
when calculating spawns using the NPC tool, it calls GlobalNPC.SpawnNPC on vanilla NPCs, which is explicitely listed in its spec as not possible 
this may result in misleading spawn rates depending on the modders code 
also looks like its not called by modders toolkit at all for modded npcs, which is weird
put a breakpoint in it and checked for explicitely modded types and no matter how often I clicked it, nothing came up. only once it did randomly but the stacktrace was just the vanilla code as expected
at Terraria.ModLoader.NPCLoader.SpawnNPC(Int32 type, Int32 tileX, Int32 tileY) in tModLoader\Terraria\ModLoader\NPCLoader.cs:line 982
   at Terraria.NPC.SpawnNPC() in tModLoader\Terraria\NPC.cs:line 64218
the reason im doing this is cause I need to replicate the code terraria uses to replace (modded) slimes to a special golden variant (golden slime), and testing this is a big pain because MT seems to not show the spawn rate
direwolf420 — 05/20/2023 5:29 AM
the code works, it's just 
if (matches condition to be replaced) slime.SetDefaults(golden variant);

Report from discord: https://discord.com/channels/276235094622994433/561553771809865739/1109423350176034916