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

◆ ShootFromCannon()

static void Terraria.WorldGen.ShootFromCannon ( int x,
int y,
int angle,
int ammo,
int Damage,
float KnockBack,
int owner,
bool fromWire )
inlinestatic

Definition at line 41978 of file WorldGen.cs.

41979 {
41980 float num = 14f;
41981 float num2 = 0f;
41982 float num3 = 0f;
41983 int type = 162;
41984 if (ammo == 2)
41985 {
41986 type = 281;
41987 }
41988 if (ammo == 3)
41989 {
41990 type = 178;
41991 }
41992 if (ammo == 4)
41993 {
41994 type = 601;
41995 num = 3f;
41996 }
41997 if (ammo == 5)
41998 {
41999 type = 601;
42000 num = 3f;
42001 }
42002 int num4 = 0;
42003 int num5 = 0;
42004 if (ammo == 5)
42005 {
42006 num4 = 1;
42007 }
42008 if (ammo == 2)
42009 {
42010 num5 = owner + 1;
42011 }
42012 if (angle == 0)
42013 {
42014 num2 = 10f;
42015 num3 = 0f;
42016 }
42017 if (angle == 1)
42018 {
42019 num2 = 7.5f;
42020 num3 = -2.5f;
42021 }
42022 if (angle == 2)
42023 {
42024 num2 = 5f;
42025 num3 = -5f;
42026 }
42027 if (angle == 3)
42028 {
42029 num2 = 2.75f;
42030 num3 = -6f;
42031 }
42032 if (angle == 4)
42033 {
42034 num2 = 0f;
42035 num3 = -10f;
42036 }
42037 if (angle == 5)
42038 {
42039 num2 = -2.75f;
42040 num3 = -6f;
42041 }
42042 if (angle == 6)
42043 {
42044 num2 = -5f;
42045 num3 = -5f;
42046 }
42047 if (angle == 7)
42048 {
42049 num2 = -7.5f;
42050 num3 = -2.5f;
42051 }
42052 if (angle == 8)
42053 {
42054 num2 = -10f;
42055 num3 = 0f;
42056 }
42057 Vector2 vector = new Vector2((x + 2) * 16, (y + 2) * 16);
42058 float num6 = num2;
42059 float num7 = num3;
42060 float num8 = (float)Math.Sqrt(num6 * num6 + num7 * num7);
42061 if (ammo == 4 || ammo == 5)
42062 {
42063 if (angle == 4)
42064 {
42065 vector.X += 5f;
42066 }
42067 vector.Y += 5f;
42068 }
42069 bool flag = true;
42070 if (ammo == 2 && !BunnyCannonCanFire())
42071 {
42072 flag = false;
42073 }
42074 if (!flag)
42075 {
42076 return;
42077 }
42078 num8 = num / num8;
42079 num6 *= num8;
42080 num7 *= num8;
42081 if (Main.myPlayer != owner && Main.netMode == 2 && (ammo == 4 || ammo == 5))
42082 {
42083 NetMessage.SendData(108, owner, -1, null, Damage, KnockBack, x, y, angle, ammo, owner);
42084 return;
42085 }
42086 if (Main.netMode == 2)
42087 {
42088 owner = Main.myPlayer;
42089 }
42090 int num9 = Projectile.NewProjectile(GetProjectileSource_PlayerOrWires(x, y, fromWire, Main.player[owner]), vector.X, vector.Y, num6, num7, type, Damage, KnockBack, owner, num4, num5);
42091 Main.projectile[num9].originatedFromActivableTile = true;
42092 }
static double Sqrt(double d)
static IEntitySource GetProjectileSource_PlayerOrWires(int x, int y, bool fromWiring, Player player)
Definition WorldGen.cs:1333
static bool BunnyCannonCanFire()

References Terraria.GameContent.Damage, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Projectile.NewProjectile(), Terraria.Main.player, Terraria.Main.projectile, Terraria.NetMessage.SendData(), System.Math.Sqrt(), and System.type.

Referenced by Terraria.MessageBuffer.GetData(), Terraria.Wiring.HitWireSingle(), Terraria.Player.ShootFromCannon(), and Terraria.Player.TileInteractionsUse().