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:
parent
86c180c156
commit
90505435ba
2 changed files with 10 additions and 3 deletions
|
|
@ -153,7 +153,14 @@ namespace TShockAPI
|
|||
out spawnTileY);
|
||||
int npcid = NPC.NewNPC(spawnTileX * 16, spawnTileY * 16, type, 0);
|
||||
// This is for special slimes
|
||||
Main.npc[npcid].SetDefaults(name);
|
||||
if (type == 1)
|
||||
{
|
||||
Main.npc[npcid].SetDefaults(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.npc[npcid].netDefaults(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue