Added support to spawn all types of slimes (have to use the full exact name)
Added SpawnNPC in TSServerPlayer Warn user if multiple mob with name are found
This commit is contained in:
parent
7bccfbe441
commit
51aa337839
4 changed files with 98 additions and 67 deletions
|
|
@ -464,31 +464,6 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
//TODO : Notify the player if there is more than one match. (or do we want a First() kinda thing?)
|
||||
public static int GetNPCID(string name, bool exact = false)
|
||||
{
|
||||
NPC npc = new NPC();
|
||||
for (int i = 1; i < Main.maxNPCTypes; i++)
|
||||
{
|
||||
if (exact)
|
||||
{
|
||||
//Method #1 - must be exact match, allows support for different coloured slimes
|
||||
npc.SetDefaults(name);
|
||||
if (npc.name == name)
|
||||
return i;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Method #2 - allows impartial matching
|
||||
name = name.ToLower();
|
||||
npc.SetDefaults(i);
|
||||
if (npc.name.ToLower().StartsWith(name))
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int GetItemID(string name)
|
||||
{
|
||||
Item item = new Item();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue