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

◆ AI_125_ClumsySlimeBalloon()

void Terraria.NPC.AI_125_ClumsySlimeBalloon ( )
inlineprivate

Definition at line 36812 of file NPC.cs.

36813 {
36814 if (localAI[0] == 0f && Main.netMode != 1)
36815 {
36816 TargetClosest();
36817 localAI[0] = 1f;
36818 netUpdate = true;
36819 }
36821 rotation = velocity.X * 0.05f;
36823 float num = float.PositiveInfinity;
36824 int num2 = 0;
36826 if (!targetData.Invalid)
36827 {
36828 zero = targetData.Center - base.Bottom;
36829 if (zero.Y < 0f)
36830 {
36831 num2 = (int)zero.Y / -16;
36832 }
36833 num = zero.Length();
36834 if (direction != Math.Sign(zero.X))
36835 {
36836 num2 = 0;
36837 }
36838 }
36839 if (wet || collideX || (collideY && oldVelocity.Y < 0f))
36840 {
36841 float num3 = oldVelocity.X + (float)(direction * 8);
36842 position.X -= num3;
36844 direction *= -1;
36845 velocity.X = direction * 2;
36846 life = -1;
36847 HitEffect();
36848 active = false;
36849 netUpdate = true;
36851 return;
36852 }
36853 if (collideY)
36854 {
36855 velocity.Y = ((oldVelocity.Y > 0f) ? 1 : (-1));
36857 }
36858 float num4 = 3f + Math.Abs(Main.windSpeedTarget) * 2f;
36860 {
36861 velocity.X += (float)direction * 0.04f;
36862 if (velocity.X * (float)direction < 0f)
36863 {
36864 if (Math.Abs(velocity.X) > num4)
36865 {
36866 velocity.X += (float)direction * 0.15f;
36867 }
36868 else
36869 {
36870 velocity.X += (float)direction * 0.1f;
36871 }
36872 }
36873 else if (Math.Abs(velocity.X) > num4)
36874 {
36875 velocity.X = (float)direction * num4;
36876 }
36877 }
36878 int num5 = (int)((position.X + (float)(width / 2)) / 16f) + direction;
36879 int num6 = (int)((position.Y + (float)height) / 16f);
36880 bool flag = true;
36881 int num7 = 8 + num2;
36882 bool flag2 = false;
36883 for (int i = num6; i < num6 + num7; i++)
36884 {
36885 if (Main.tile[num5, i] == null)
36886 {
36887 Main.tile[num5, i] = new Tile();
36888 }
36889 if ((Main.tile[num5, i].nactive() && Main.tileSolid[Main.tile[num5, i].type]) || Main.tile[num5, i].liquid > 0)
36890 {
36891 if (i < num6 + 5 + num2)
36892 {
36893 flag2 = true;
36894 }
36895 flag = false;
36896 break;
36897 }
36898 }
36899 if (num < 400f && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height))
36900 {
36901 float num8 = 2f;
36902 float num9 = 0.035f;
36903 if (base.Center.Y + (float)(height / 4) > Main.player[target].position.Y + (float)(Main.player[target].height / 4) && velocity.Y > 0f - num8)
36904 {
36905 velocity.Y -= num9;
36906 if (velocity.Y > 0f)
36907 {
36908 velocity.Y -= num9;
36909 }
36910 }
36911 else if (base.Center.Y + (float)(height / 4) < Main.player[target].position.Y + (float)(Main.player[target].height / 4) && velocity.Y < num8)
36912 {
36913 velocity.Y += num9;
36914 if (velocity.Y < 0f)
36915 {
36916 velocity.Y += num9;
36917 }
36918 }
36919 }
36920 else
36921 {
36922 if (flag)
36923 {
36924 velocity.Y += 0.05f;
36925 }
36926 else
36927 {
36928 velocity.Y -= 0.1f;
36929 }
36930 if (flag2)
36931 {
36932 velocity.Y -= 0.2f;
36933 }
36934 if (velocity.Y > 2f)
36935 {
36936 velocity.Y = 2f;
36937 }
36938 if (velocity.Y < -4f)
36939 {
36940 velocity.Y = -4f;
36941 }
36942 }
36943 }
static double Abs(double value)
static int Sign(decimal value)
Definition Math.cs:1202
static void PlaySound(int type, Vector2 position, int style=1)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
Vector2 oldVelocity
Definition Entity.cs:20
float[] localAI
Definition NPC.cs:449
int spriteDirection
Definition NPC.cs:517
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:69934
NPCAimedTarget GetTargetData(bool ignorePlayerTankPets=true)
Definition NPC.cs:864
bool collideX
Definition NPC.cs:511
bool collideY
Definition NPC.cs:513
LegacySoundStyle DeathSound
Definition NPC.cs:475
float rotation
Definition NPC.cs:501
void HitEffect(int hitDirection=0, double dmg=10.0)
Definition NPC.cs:78386
int life
Definition NPC.cs:477
bool netUpdate
Definition NPC.cs:507
int target
Definition NPC.cs:459

References System.Math.Abs(), Terraria.Entity.active, Terraria.Collision.CanHit(), Terraria.NPC.collideX, Terraria.NPC.collideY, Terraria.NPC.DeathSound, Terraria.Entity.direction, Terraria.NPC.GetTargetData(), Terraria.Entity.height, Terraria.NPC.HitEffect(), Terraria.NPC.life, Terraria.NPC.localAI, Terraria.Main.netMode, Terraria.NPC.netUpdate, Terraria.Entity.oldVelocity, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.NPC.rotation, System.Math.Sign(), Terraria.NPC.spriteDirection, Terraria.NPC.target, Terraria.NPC.TargetClosest(), Terraria.DataStructures.Tile, Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Entity.velocity, Terraria.Entity.wet, Terraria.Entity.width, Terraria.Main.windSpeedTarget, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.NPC.AI().