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,8 +153,15 @@ namespace TShockAPI
|
||||||
out spawnTileY);
|
out spawnTileY);
|
||||||
int npcid = NPC.NewNPC(spawnTileX * 16, spawnTileY * 16, type, 0);
|
int npcid = NPC.NewNPC(spawnTileX * 16, spawnTileY * 16, type, 0);
|
||||||
// This is for special slimes
|
// This is for special slimes
|
||||||
|
if (type == 1)
|
||||||
|
{
|
||||||
Main.npc[npcid].SetDefaults(name);
|
Main.npc[npcid].SetDefaults(name);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Main.npc[npcid].netDefaults(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StrikeNPC(int npcid, int damage, float knockBack, int hitDirection)
|
public void StrikeNPC(int npcid, int damage, float knockBack, int hitDirection)
|
||||||
|
|
|
||||||
|
|
@ -420,9 +420,9 @@ namespace TShockAPI
|
||||||
for (int i = -17; i < Main.maxNPCTypes; i++)
|
for (int i = -17; i < Main.maxNPCTypes; i++)
|
||||||
{
|
{
|
||||||
npc.netDefaults(i);
|
npc.netDefaults(i);
|
||||||
if (npc.name.ToLower() == nameLower)
|
if (npc.name.ToLower() == nameLower || npc.displayName.ToLower() == nameLower)
|
||||||
return new List<NPC> { npc };
|
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());
|
found.Add((NPC)npc.Clone());
|
||||||
}
|
}
|
||||||
return found;
|
return found;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue