TModLoader v1.4.4.9
TModLoader 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 85761 of file NPC.cs.

85762 {
85763 int num = -1;
85764 if (Main.netMode == 1)
85765 {
85766 NetMessage.SendData(71, -1, -1, null, x, y, Type, Style);
85767 }
85768 else if (Type >= 0 && (Main.npcCatchable[Type] || who == Main.myPlayer) && CanReleaseNPCs(who))
85769 {
85770 switch (Type)
85771 {
85772 case 583:
85773 case 584:
85774 case 585:
85775 num = NewNPC(GetSpawnSource_NPCRelease(who), x, y, Type);
85776 Main.npc[num].releaseOwner = (short)who;
85777 Main.npc[num].ai[2] = 2f;
85778 Main.npc[num].TargetClosest();
85779 Main.npc[num].ai[3] = 0f;
85780 Main.npc[num].netUpdate = true;
85781 break;
85782 case 356:
85783 num = NewNPC(GetSpawnSource_NPCRelease(who), x, y, Type);
85784 Main.npc[num].ai[2] = Style;
85785 Main.npc[num].releaseOwner = (short)who;
85786 break;
85787 case 148:
85788 {
85789 int num3 = Type + Main.rand.Next(2);
85791 Main.npc[num].releaseOwner = (short)who;
85792 break;
85793 }
85794 case 614:
85795 {
85796 num = NewNPC(GetSpawnSource_NPCRelease(who), x, y, Type);
85797 Main.npc[num].releaseOwner = (short)who;
85798 int num2 = Main.player[who].direction;
85799 if (Style > 2)
85800 {
85801 Style -= 2;
85802 Main.npc[num].SpawnedFromStatue = true;
85803 Main.npc[num].CanBeReplacedByOtherNPCs = true;
85804 }
85805 if (Style == 1)
85806 {
85807 num2 = 1;
85808 }
85809 if (Style == 2)
85810 {
85811 num2 = -1;
85812 }
85813 Main.npc[num].direction = num2;
85814 Main.npc[num].spriteDirection = num2;
85815 Main.npc[num].netUpdate = true;
85816 break;
85817 }
85818 default:
85819 num = NewNPC(GetSpawnSource_NPCRelease(who), x, y, Type);
85820 Main.npc[num].releaseOwner = (short)who;
85821 break;
85822 }
85823 }
85824 return num;
85825 }
static bool CanReleaseNPCs(int who)
Definition NPC.cs:85725
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)
Spawns an NPC into the game world with the given type. This method should not be called on multipla...
Definition NPC.cs:91239
static IEntitySource GetSpawnSource_NPCRelease(int whoReleasedIt)
Definition NPC.cs:107528

References 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: