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

◆ AI_AttemptToFindTeleportSpot()

bool Terraria.NPC.AI_AttemptToFindTeleportSpot ( ref Vector2 chosenTile,
int targetTileX,
int targetTileY,
int rangeFromTargetTile = 20,
int telefragPreventionDistanceInTiles = 5,
int solidTileCheckFluff = 1,
bool solidTileCheckCentered = false,
bool teleportInAir = false )
inline

Definition at line 13811 of file NPC.cs.

13812 {
13813 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
13814 //IL_0011: Unknown result type (might be due to invalid IL or missing references)
13815 //IL_0272: Unknown result type (might be due to invalid IL or missing references)
13816 //IL_0277: Unknown result type (might be due to invalid IL or missing references)
13817 //IL_0204: Unknown result type (might be due to invalid IL or missing references)
13818 //IL_0209: Unknown result type (might be due to invalid IL or missing references)
13819 //IL_020b: Unknown result type (might be due to invalid IL or missing references)
13820 //IL_022f: Unknown result type (might be due to invalid IL or missing references)
13821 //IL_0234: Unknown result type (might be due to invalid IL or missing references)
13822 //IL_0243: Unknown result type (might be due to invalid IL or missing references)
13823 int num = (int)base.Center.X / 16;
13824 int num2 = (int)base.Center.Y / 16;
13825 int num3 = 0;
13826 bool flag = false;
13827 float num4 = 20f;
13828 if (Math.Abs(num * 16 - targetTileX * 16) + Math.Abs(num2 * 16 - targetTileY * 16) > 2000)
13829 {
13830 num3 = 100;
13831 flag = false;
13832 }
13833 Rectangle rectangle = default(Rectangle);
13834 while (!flag && num3 < 100)
13835 {
13836 num3++;
13838 for (int i = Main.rand.Next(targetTileY - rangeFromTargetTile, targetTileY + rangeFromTargetTile + 1); i < targetTileY + rangeFromTargetTile; i++)
13839 {
13840 if ((i >= num2 - 1 && i <= num2 + 1 && num5 >= num - 1 && num5 <= num + 1) || (!teleportInAir && !Main.tile[num5, i].nactive()))
13841 {
13842 continue;
13843 }
13844 bool flag2 = true;
13845 if ((type == 32 || (type >= 281 && type <= 286)) && !Main.wallDungeon[Main.tile[num5, i - 1].wall])
13846 {
13847 if (!AnyNPCs(35))
13848 {
13849 flag2 = false;
13850 }
13851 }
13852 else if (Main.tile[num5, i - 1].lava())
13853 {
13854 flag2 = false;
13855 }
13856 if (!flag2 || (!teleportInAir && !Main.tileSolid[Main.tile[num5, i].type]) || !((!solidTileCheckCentered) ? (!Collision.SolidTiles(num5 - solidTileCheckFluff, num5 + solidTileCheckFluff, i - 3 - solidTileCheckFluff, i - 1)) : (!Collision.SolidTiles(num5 - solidTileCheckFluff, num5 + solidTileCheckFluff, i - solidTileCheckFluff, i + solidTileCheckFluff))))
13857 {
13858 continue;
13859 }
13860 ((Rectangle)(ref rectangle))._002Ector(num5 * 16, i * 16, 16, 16);
13862 for (int j = 0; j < Main.player.Length; j++)
13863 {
13864 Player player = Main.player[j];
13865 if (player != null && player.active && !player.DeadOrGhost)
13866 {
13867 Rectangle value = player.Hitbox;
13868 Rectangle value2 = value.Modified((int)(player.velocity.X * num4), (int)(player.velocity.Y * num4), 0, 0);
13869 Rectangle.Union(ref value2, ref value, ref value2);
13870 if (((Rectangle)(ref value2)).Intersects(rectangle))
13871 {
13872 flag2 = false;
13873 flag = false;
13874 break;
13875 }
13876 }
13877 }
13878 if (flag2)
13879 {
13880 chosenTile = new Vector2((float)num5, (float)i);
13881 flag = true;
13882 }
13883 break;
13884 }
13885 }
13886 return flag;
13887 }
float value
How many copper coins the NPC will drop when killed (100 copper coins = 1 silver coin etc....
Definition NPC.cs:1156
static bool AnyNPCs(int Type)
Returns true if there are any active NPC in the world of the given NPC type (F:Terraria....
Definition NPC.cs:106615
int type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
Definition NPC.cs:990

References Terraria.Entity.active, Terraria.NPC.AnyNPCs(), Terraria.Player.DeadOrGhost, Terraria.Entity.Hitbox, Terraria.Main.player, Terraria.Main.rand, Terraria.Collision.SolidTiles(), Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.NPC.type, Terraria.NPC.value, and Terraria.Main.wallDungeon.

Referenced by Terraria.NPC.AI_003_Fighters(), and Terraria.NPC.VanillaAI_Inner().

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