Improved NPC spawning functionality via /sm.

Display names can now be used to find NPCs.
Spawning by ID should now spawn unique NPCs, when multiple NPCs share the same name.
Closes #1383
This commit is contained in:
White 2017-03-13 12:00:46 +10:30
parent 86c180c156
commit 90505435ba
2 changed files with 10 additions and 3 deletions

View file

@ -153,8 +153,15 @@ namespace TShockAPI
out spawnTileY);
int npcid = NPC.NewNPC(spawnTileX * 16, spawnTileY * 16, type, 0);
// This is for special slimes
if (type == 1)
{
Main.npc[npcid].SetDefaults(name);
}
else
{
Main.npc[npcid].netDefaults(type);
}
}
}
public void StrikeNPC(int npcid, int damage, float knockBack, int hitDirection)

View file

@ -420,9 +420,9 @@ namespace TShockAPI
for (int i = -17; i < Main.maxNPCTypes; i++)
{
npc.netDefaults(i);
if (npc.name.ToLower() == nameLower)
if (npc.name.ToLower() == nameLower || npc.displayName.ToLower() == nameLower)
return new List<NPC> { npc };
if (npc.name.ToLower().StartsWith(nameLower))
if (npc.name.ToLower().StartsWith(nameLower) || npc.displayName.ToLower().StartsWith(nameLower))
found.Add((NPC)npc.Clone());
}
return found;