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

◆ AI_134_Ballista()

void Terraria.Projectile.AI_134_Ballista ( )
inlineprivate

Definition at line 57794 of file Projectile.cs.

57795 {
57796 //IL_02dd: Unknown result type (might be due to invalid IL or missing references)
57797 float shot_range = 900f;
57798 float deadBottomAngle = 0.75f;
57799 Vector2 center = base.Center;
57800 int num = 680;
57801 int num2 = 12;
57802 float num3 = 16f;
57803 int num4 = 1;
57804 int num5 = 5;
57805 int num6 = 5;
57806 if (Main.player[owner].setSquireT2)
57807 {
57808 num3 = 21f;
57809 }
57811 num2 = num6;
57812 int num7 = type;
57813 if (num7 == 677)
57814 {
57815 center.Y -= 4f;
57816 }
57817 if (ai[0] == 0f)
57818 {
57819 direction = (spriteDirection = Main.player[owner].direction);
57820 ai[0] = 1f;
57821 ai[1] = 0f;
57822 netUpdate = true;
57823 if (direction == -1)
57824 {
57825 rotation = (float)Math.PI;
57826 }
57827 }
57828 if (ai[0] == 1f)
57829 {
57830 frame = 0;
57831 bool flag = false;
57832 if (Main.player[owner].ballistaPanic && ai[1] > 60f)
57833 {
57834 ai[1] = 60f;
57835 }
57836 if (Main.player[owner].ballistaPanic && Main.player[owner].setSquireT3 && ai[1] > 30f)
57837 {
57838 ai[1] = 30f;
57839 }
57840 if (ai[1] > 0f)
57841 {
57842 ai[1] -= 1f;
57843 }
57844 else
57845 {
57846 flag = true;
57847 }
57849 if (num8 != -1)
57850 {
57851 Vector2 vector = (vector = (Main.npc[num8].Center - center).SafeNormalize(Vector2.UnitY));
57852 rotation = rotation.AngleLerp(vector.ToRotation(), 0.08f);
57853 if (rotation > (float)Math.PI / 2f || rotation < -(float)Math.PI / 2f)
57854 {
57855 direction = -1;
57856 }
57857 else
57858 {
57859 direction = 1;
57860 }
57861 if (flag && owner == Main.myPlayer)
57862 {
57864 ai[0] = 2f;
57865 ai[1] = 0f;
57866 netUpdate = true;
57867 }
57868 }
57869 else
57870 {
57871 float targetAngle = 0f;
57872 if (direction == -1)
57873 {
57874 targetAngle = (float)Math.PI;
57875 }
57876 rotation = rotation.AngleLerp(targetAngle, 0.05f);
57877 }
57878 }
57879 else if (ai[0] == 2f)
57880 {
57881 frame = num4 + (int)(ai[1] / (float)num6);
57882 if (ai[1] == (float)num2)
57883 {
57885 Vector2 vector2 = new Vector2(direction, 0f);
57887 if (num9 != -1)
57888 {
57889 vector2 = (Main.npc[num9].Center - center).SafeNormalize(Vector2.UnitX * direction);
57890 }
57891 rotation = vector2.ToRotation();
57892 if (rotation > (float)Math.PI / 2f || rotation < -(float)Math.PI / 2f)
57893 {
57894 direction = -1;
57895 }
57896 else
57897 {
57898 direction = 1;
57899 }
57901 if (owner == Main.myPlayer)
57902 {
57904 }
57905 }
57906 if ((ai[1] += 1f) >= (float)(num5 * num6))
57907 {
57908 ai[0] = 1f;
57910 }
57911 }
57913 tileCollide = true;
57914 velocity.Y += 0.2f;
57915 }
const double PI
Definition Math.cs:16
static int Sign(decimal value)
Definition Math.cs:1202
static SlotId PlayTrackedSound(SoundStyle style, Vector2 position)
static readonly LegacySoundStyle DD2_BallistaTowerShot
Definition SoundID.cs:788
int AI_134_Ballista_FindTarget(float shot_range, float deadBottomAngle, Vector2 shootingSpot)
static int GetBallistraShotDelay(Player player)
IEntitySource GetProjectileSource_FromThis()
static int NewProjectile(IEntitySource spawnSource, Vector2 position, Vector2 velocity, int Type, int Damage, float KnockBack, int Owner=-1, float ai0=0f, float ai1=0f, float ai2=0f)

References Terraria.ID.SoundID.DD2_BallistaTowerShot, Terraria.Main.myPlayer, Terraria.Main.npc, System.Math.PI, Terraria.Main.player, Terraria.Audio.SoundEngine.PlayTrackedSound(), System.Math.Sign(), System.type, Microsoft.Xna.Framework.Vector2.UnitX, and Microsoft.Xna.Framework.Vector2.UnitY.