Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ReleaseNPC()

static int Terraria.NPC.ReleaseNPC ( int x,
int y,
int Type,
int Style,
int who )
inlinestatic

Definition at line 72344 of file NPC.cs.

72345 {
72346 int num = -1;
72347 if (Main.netMode == 1)
72348 {
72349 NetMessage.SendData(71, -1, -1, null, x, y, Type, Style);
72350 }
72351 else if (Type >= 0 && Type < NPCID.Count && (Main.npcCatchable[Type] || who == Main.myPlayer) && CanReleaseNPCs(who))
72352 {
72353 switch (Type)
72354 {
72355 case 583:
72356 case 584:
72357 case 585:
72359 Main.npc[num].releaseOwner = (short)who;
72360 Main.npc[num].ai[2] = 2f;
72361 Main.npc[num].TargetClosest();
72362 Main.npc[num].ai[3] = 0f;
72363 Main.npc[num].netUpdate = true;
72364 break;
72365 case 356:
72367 Main.npc[num].ai[2] = Style;
72368 Main.npc[num].releaseOwner = (short)who;
72369 break;
72370 case 148:
72371 {
72372 int num3 = Type + Main.rand.Next(2);
72374 Main.npc[num].releaseOwner = (short)who;
72375 break;
72376 }
72377 case 614:
72378 {
72380 Main.npc[num].releaseOwner = (short)who;
72381 int num2 = Main.player[who].direction;
72382 if (Style > 2)
72383 {
72384 Style -= 2;
72385 Main.npc[num].SpawnedFromStatue = true;
72386 Main.npc[num].CanBeReplacedByOtherNPCs = true;
72387 }
72388 if (Style == 1)
72389 {
72390 num2 = 1;
72391 }
72392 if (Style == 2)
72393 {
72394 num2 = -1;
72395 }
72396 Main.npc[num].direction = num2;
72397 Main.npc[num].spriteDirection = num2;
72398 Main.npc[num].netUpdate = true;
72399 break;
72400 }
72401 default:
72403 Main.npc[num].releaseOwner = (short)who;
72404 break;
72405 }
72406 }
72407 return num;
72408 }
static readonly short Count
Definition NPCID.cs:11744
static bool CanReleaseNPCs(int who)
Definition NPC.cs:72308
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Definition NPC.cs:77654
static IEntitySource GetSpawnSource_NPCRelease(int whoReleasedIt)
Definition NPC.cs:87511

References Terraria.ID.NPCID.Count, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Main.npc, Terraria.Main.npcCatchable, Terraria.Main.player, Terraria.Main.rand, and Terraria.NetMessage.SendData().

Referenced by Terraria.MessageBuffer.GetData(), Terraria.Item.GetShimmered(), Terraria.Projectile.HandleMovement(), and Terraria.Player.ItemCheck_ReleaseCritter().