Example #1
0
 public override void Update(TerraGuardian tg, GuardianSpecialAttackData data)
 {
     tg.ShowOffHand = false;
     if (data.Step < 4)
     {
         Lighting.AddLight(tg.CenterPosition, Vector3.One);
     }
     if (data.FirstFrame)
     {
         if (data.Step == 4)
         {
             FrameID = 0;
             //
             Vector2 AimDirectionChange = tg.AimDirection;
             tg.LookingLeft = tg.Position.X - tg.AimDirection.X >= 0;
             float AngleChecker = MathHelper.WrapAngle((float)Math.Atan2((tg.CenterY - AimDirectionChange.Y) * tg.GravityDirection, tg.Position.X - AimDirectionChange.X));
             float ArmAngle     = tg.CalculateAimingUseAnimation(AngleChecker);
             if (ArmAngle < -0.75f)
             {
                 FrameID = 0;
             }
             else if (ArmAngle > 0.6f)
             {
                 FrameID = 3;
             }
             else if (ArmAngle >= -0.2f)
             {
                 FrameID = 1;
             }
             else
             {
                 FrameID = 2;
             }
             //
             int BackupLArmFrame = tg.LeftArmAnimationFrame, BackupRArmFrame = tg.RightArmAnimationFrame;
             for (byte i = 0; i < 2; i++)
             {
                 if ((i == 0 && TerraGuardian.UsingLeftArmAnimation) || (i == 1 && TerraGuardian.UsingRightArmAnimation))
                 {
                     continue;
                 }
                 if (i == 0)
                 {
                     tg.LeftArmAnimationFrame = 17 + FrameID;
                 }
                 else
                 {
                     tg.RightArmAnimationFrame = 17 + FrameID;
                 }
                 Vector2 ProjectileSpawnPosition = (i == 0 ? tg.GetGuardianLeftHandPosition : tg.GetGuardianRightHandPosition);
                 if (i == 0)
                 {
                     tg.LeftArmAnimationFrame = BackupLArmFrame;
                 }
                 else
                 {
                     tg.RightArmAnimationFrame = BackupRArmFrame;
                 }
                 Vector2 ShotDirection = tg.AimDirection - ProjectileSpawnPosition;
                 ShotDirection.Normalize();
                 ShotDirection *= 8f;
                 int Damage     = GetAttackDamage(tg);
                 int Proj       = IsAwakenedVersion ? Terraria.ModLoader.ModContent.ProjectileType <Projectiles.CrimsonFlameProjectile>() : Terraria.ModLoader.ModContent.ProjectileType <Projectiles.HellFlame>();
                 int resultproj = Projectile.NewProjectile(ProjectileSpawnPosition, ShotDirection,
                                                           Proj,
                                                           Damage, 6, (tg.OwnerPos > -1 ? tg.OwnerPos : Main.myPlayer));
                 tg.SetProjectileOwnership(resultproj);
                 Main.projectile[resultproj].scale = tg.Scale;
             }
         }
     }
     if (data.Time >= 6)
     {
         if (data.Step >= 4)
         {
             data.EndUse();
             return;
         }
         data.ChangeStep(TimeToDiscount: 6);
     }
 }
Example #2
0
        public override void Update(TerraGuardian tg, GuardianSpecialAttackData data)
        {
            if (data.FirstFrame)
            {
                Vector2 ProjectilePosition = Vector2.Zero;
                Vector2 AimPosition        = tg.AimDirection - tg.CenterPosition;
                float   Angle = Math.Abs(MathHelper.WrapAngle((float)Math.Atan2(AimPosition.Y, AimPosition.X)));
                if (AimPosition.X < 0)
                {
                    Angle = (float)Math.PI - Angle;
                }
                int LeftArmFrame = 57;
                if (Angle < 30 * 0.017453f) //Middle
                {
                    if (tg.Velocity.Y != 0)
                    {
                        LeftArmFrame = 61;
                    }
                }
                else if (AimPosition.Y > 0) //Down
                {
                    if (tg.Velocity.Y != 0)
                    {
                        LeftArmFrame = 60;
                    }
                    else
                    {
                        LeftArmFrame = 58;
                    }
                }
                else //Up
                {
                    if (tg.Velocity.Y != 0)
                    {
                        LeftArmFrame = 62;
                    }
                    else
                    {
                        LeftArmFrame = 59;
                    }
                }
                switch (LeftArmFrame)
                {
                case 57:
                    ProjectilePosition = new Vector2(46, 43);
                    break;

                case 58:
                    ProjectilePosition = new Vector2(46, 47);
                    break;

                case 59:
                    ProjectilePosition = new Vector2(48, 34);
                    break;

                case 60:
                    ProjectilePosition = new Vector2(42, 43);
                    break;

                case 61:
                    ProjectilePosition = new Vector2(46, 37);
                    break;

                case 62:
                    ProjectilePosition = new Vector2(45, 30);
                    break;
                }
                ProjectilePosition  *= 2;
                ProjectilePosition.X = ProjectilePosition.X - tg.Base.SpriteWidth * 0.5f;
                if (tg.LookingLeft)
                {
                    ProjectilePosition.X *= -1;
                }
                ProjectilePosition.Y = -tg.Base.SpriteHeight + ProjectilePosition.Y;
                ProjectilePosition   = tg.PositionWithOffset + ProjectilePosition * tg.Scale;
                AimPosition.Normalize();
                for (int i = 0; i < 4; i++)
                {
                    Dust.NewDust(ProjectilePosition, 2, 2, 132, AimPosition.X, AimPosition.Y);
                }
                int Damage = GetDamage(tg);
                int ID     = Projectile.NewProjectile(ProjectilePosition, AimPosition * 14f, Terraria.ModLoader.ModContent.ProjectileType <Projectiles.CannonBlast>(),
                                                      Damage, 0.06f, tg.GetSomeoneToSpawnProjectileFor);
                //Main.PlaySound(Terraria.ModLoader.SoundLoader.customSoundType, tg.CenterPosition, Terraria.ModLoader.SoundLoader.GetSoundSlot(Terraria.ModLoader.SoundType.Custom, "Creatures/CaptainStench/Sounds/BlasterSound"));
                Main.PlaySound(2, tg.CenterPosition, 20);
                Main.projectile[ID].scale     = tg.Scale;
                Main.projectile[ID].netUpdate = true;
                tg.SetProjectileOwnership(ID);
            }
            if (data.Time >= 8)
            {
                data.EndUse();
            }
        }