Pryaxis / TShock

☕️⚡️TShock provides Terraria servers with server-side characters, anti-cheat, and community management tools.
GNU General Public License v3.0
2.41k stars 377 forks source link

Fixing and improving /spawnmob command #1383

Closed OnsenManju closed 7 years ago

OnsenManju commented 7 years ago

As reported #1350 and #1380, current /spawnmob(/sm) command can't summon mobs that have segmented bodies (like worms) and multiple types with single name (like big mimic) properly.

1st issue: Segmented-mob should be summoned by its head part (e.g. "eater of worlds head") and multiple typed mobs should be summoned by its specific name (e.g. "crimson mimic", not "big mimic"). /sm is using TShock.Utils.GetNPCByName() for searching by mob's name, but it uses npc.name, so

I propose using npc.displayName instead of npc.name in GetNPCByName() to improve that, and also it becomes able to summon by its union name (like /sm "eater of worlds", because the head part will be found at first when searching).

2nd issue: In TSPlayer.Server.SpawnNPC(), name is set for new mob intensionally. Maybe this was added for the variety of "blue slime" (type=1),

[Special Slimes]
type NPC.name
1    Jungle Slime
1    Yellow Slime
1    Red Slime
1    Purple Slime
1    Black Slime
1    Baby Slime
1    Green Slime

but it causes

So, how about like this?

// This is for special slimes
if (type == 1)
{
    Main.npc[npcid].SetDefaults(displayName);
}
else
{
    Main.npc[npcid].SetDefaults(type);
}

I'd appreciate if the devs consider it.

OnsenManju commented 7 years ago

Sample plugin for testing (API 2.0) https://github.com/OnsenManju/SpawnTest

command: /findmob(/fm) <name> /spawntest(/st) <mob ID or name> [amount]

p.s. In case of Moon Lord, it needs to use /st "moon lord's core" or /st 398.

Kojirremer commented 7 years ago

Just curious, but is this issue related to birds spawned with /sm always being the basic type, even when using Blue Jay and Cardigan's IDs?

tlworks commented 7 years ago

@Kojirremer Yeah, same goes for Salamanders and Slugs.

OnsenManju commented 7 years ago

@Kojirremer, @tlworks Probably.

Birds are similar as big mimics.

/findmob bird
Search result:
type=74 Main.npcName="Bird" NPC.name="Bird" NPC.displayName="Bird"
type=297 Main.npcName="Blue Jay" NPC.name="Bird" NPC.displayName="Blue Jay"
type=298 Main.npcName="Cardinal" NPC.name="Bird" NPC.displayName="Cardinal"

Salamanders are same as scarecrows. (I'm not sure about slugs(snails?) though)

/findmob salamander
Search result:
type=498 Main.npcName="Salamander" NPC.name="Salamander" NPC.displayName="Salamander"
type=499 Main.npcName="Salamander" NPC.name="Salamander" NPC.displayName="Salamander"
type=500 Main.npcName="Salamander" NPC.name="Salamander" NPC.displayName="Salamander"
type=501 Main.npcName="Salamander" NPC.name="Salamander" NPC.displayName="Salamander"
type=502 Main.npcName="Salamander" NPC.name="Salamander" NPC.displayName="Salamander"
type=503 Main.npcName="Salamander" NPC.name="Salamander" NPC.displayName="Salamander"
type=504 Main.npcName="Salamander" NPC.name="Salamander" NPC.displayName="Salamander"
type=505 Main.npcName="Salamander" NPC.name="Salamander" NPC.displayName="Salamander"
type=506 Main.npcName="Salamander" NPC.name="Salamander" NPC.displayName="Salamander"

Sample plugin can spawn them by its ID separately. Have a try if interested.

tanpro260196 commented 7 years ago

Seem to me that /item command also have this problem. For example: you can't spawn treasure bag (using ID) of any bosses except Slime King.

OnsenManju commented 7 years ago

@tanpro260196 Perhaps so. Created new issue. #1398

QuiCM commented 7 years ago

Hi guys, we haven't forgotten about this issue, but it likely will not be worked on until the next Terraria update due to reasons.

OnsenManju commented 7 years ago

@WhiteXZ Thanks for your comment. Then I'll keep maintaining SpawnTest plugin as a temporary workaround until those issues are resolved.

hakusaro commented 7 years ago

@WhiteXZ it's worth pointing out that uh, our source says that the next update won't drop for quite some time.

OnsenManju commented 7 years ago

@WhiteXZ Thanks a lot! Now we can summon most of mobs by their basic name and specific ID!

All of the following worked successfully on new TShock 4.3.23:

QuiCM commented 7 years ago

If you find any more that don't work, feel free to reopen this and tag me :)