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

◆ AI_123_Deerclops_FindSpotToSpawnSpike()

void Terraria.NPC.AI_123_Deerclops_FindSpotToSpawnSpike ( int howMany,
int whichOne,
ref int x,
ref int y )
inlineprivate

Definition at line 37654 of file NPC.cs.

37655 {
37656 if (WorldGen.ActiveAndWalkableTile(x, y))
37657 {
37658 return;
37659 }
37661 int num = rectangle.Center.X / 16;
37662 int num2 = (rectangle.Bottom - 16) / 16;
37663 int num3 = ((num2 - y > 0) ? 1 : (-1));
37664 int num4 = y;
37665 for (int i = 1; i <= 10; i++)
37666 {
37667 int num5 = y + num3 * i;
37668 if (num5 >= 20 && num5 <= Main.maxTilesY - 20 && WorldGen.ActiveAndWalkableTile(x, num5))
37669 {
37670 num4 = num5;
37671 }
37672 }
37673 if (num4 != y)
37674 {
37675 y = num4;
37676 return;
37677 }
37678 y = (int)MathHelper.Lerp(num2, y, (float)Math.Abs(num - x) * 0.1f);
37679 for (int j = 0; j < 4; j++)
37680 {
37681 int num6 = y + j;
37682 if (num6 >= 20 && num6 <= Main.maxTilesY - 20 && WorldGen.ActiveAndWalkableTile(x, num6))
37683 {
37684 y = num6;
37685 break;
37686 }
37687 }
37688 }
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static double Abs(double value)
Rectangle targetRect
Definition NPC.cs:481

References System.Math.Abs(), Terraria.WorldGen.ActiveAndWalkableTile(), Microsoft.Xna.Framework.MathHelper.Lerp(), Terraria.Main.maxTilesY, and Terraria.NPC.targetRect.