예제 #1
0
 public override void OnHitNPC(Projectile projectile, NPC target, int damage, float knockback, bool crit)
 {
     if (IsGuardianProjectile(projectile.whoAmI))
     {
         TerraGuardian g = GuardianProj[projectile.whoAmI];
         if (damage > 0 && target.lifeMax > 5 && projectile.friendly && !projectile.hostile && projectile.aiStyle != 59)
         {
             if (target.canGhostHeal)
             {
                 if (g.HasFlag(GuardianFlags.SpectreHealSetEffect) && !g.HasFlag(GuardianFlags.MoonLeech))
                 {
                     projectile.ghostHeal(damage, target.Center);
                 }
                 if (g.HasFlag(GuardianFlags.SpectreSplashSetEffect))
                 {
                     projectile.ghostHurt(damage, target.Center);
                 }
                 if (g.HasFlag(GuardianFlags.NebulaSetEffect) && !g.HasCooldown(GuardianCooldownManager.CooldownType.NebulaCD) && Main.rand.Next(3) == 0)
                 {
                     g.AddCooldown(GuardianCooldownManager.CooldownType.NebulaCD, 30);
                     int Type = Utils.SelectRandom <int>(Main.rand, new int[3] {
                         3453, 3454, 3455
                     });
                     int number = Item.NewItem((int)target.position.X, (int)target.position.Y, target.width, target.height, Type, 1, false, 0, false, false);
                     Main.item[number].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f;
                     Main.item[number].velocity.X = (float)Main.rand.Next(10, 31) * 0.2f * (float)projectile.direction;
                 }
             }
         }
     }
 }
예제 #2
0
        public override void Update(TerraGuardian guardian)
        {
            if (Step > 0)
            {
                guardian.MoveLeft = guardian.MoveRight = guardian.MoveUp = guardian.MoveDown = guardian.Jump = false;
                IgnoreCombat      = true;
                CantUseInventory  = true;
            }
            switch (Step)
            {
            case 0:
                if (guardian.SittingOnPlayerMount)
                {
                    guardian.DoSitOnPlayerMount(false);
                }
                if (guardian.Velocity.Y == 0)
                {
                    WereTransform = guardian.HasFlag(GuardianFlags.Werewolf);
                    ChangeStep();
                }
                break;

            case 1:
                if (Time >= 11)
                {
                    ChangeStep();
                }
                break;

            case 2:
            case 3:
            case 4:
                if (Time >= 30)
                {
                    if (Step == 2)
                    {
                        guardian.UpdateStatus = true;
                    }
                    ChangeStep();
                }
                break;

            case 5:
                if (Time >= 15)
                {
                    InUse = false;
                }
                break;
            }
        }
예제 #3
0
        public override void Update(TerraGuardian tg, GuardianSpecialAttackData d)
        {
            if (d.FirstFrame && d.Step == 1)
            {
                CaptainStenchBase.CaptainStenchData data = (CaptainStenchBase.CaptainStenchData)tg.Data;
                Rectangle AttackHitbox = new Rectangle((int)(-16 * tg.Direction * tg.Scale) + (int)tg.Position.X, (int)(-110 * tg.Scale + tg.Position.Y + tg.Base.CharacterPositionYDiscount), (int)(78 * tg.Scale), (int)(94 * tg.Scale));
                if (tg.LookingLeft)
                {
                    AttackHitbox.X -= AttackHitbox.Width;
                }
                for (int i = 0; i < 4; i++)
                {
                    Vector2 Position = new Vector2(AttackHitbox.X, AttackHitbox.Y);
                    switch (i)
                    {
                    case 1:
                        Position.X += AttackHitbox.Width;
                        break;

                    case 2:
                        Position.Y += AttackHitbox.Height;
                        break;

                    case 3:
                        Position.X += AttackHitbox.Width;
                        Position.Y += AttackHitbox.Height;
                        break;
                    }
                    Dust dust = Dust.NewDustDirect(Position, 1, 1, 50);
                    dust.noGravity = true;
                    dust.velocity  = Vector2.Zero;
                }
                int   Damage       = d.Damage;
                int   CriticalRate = 4 + tg.MeleeCriticalRate;
                float Knockback    = 8f;
                byte  SwordID      = data.SwordID;
                if (SwordID > 0)
                {
                    switch (SwordID)
                    {
                    case CaptainStenchBase.AmethystFalchion:
                        break;

                    case CaptainStenchBase.TopazFalchion:
                        Knockback += 12f;
                        break;

                    case CaptainStenchBase.SapphireFalchion:
                        //Knockback *= 0.11f;
                        break;

                    case CaptainStenchBase.EmeraldFalchion:
                        CriticalRate += 50;
                        break;
                    }
                }
                bool HitSomething = false;
                for (int n = 0; n < 200; n++)
                {
                    if (Main.npc[n].active && !Main.npc[n].friendly && !tg.NpcHasBeenHit(n) && Main.npc[n].getRect().Intersects(AttackHitbox))
                    {
                        if (!Main.npc[n].dontTakeDamage)
                        {
                            int HitDirection = tg.Direction;
                            if ((HitDirection == -1 && tg.Position.X < Main.npc[n].Center.X) ||
                                (HitDirection == 1 && tg.Position.X > Main.npc[n].Center.X))
                            {
                                HitDirection *= -1;
                            }
                            bool Critical  = (Main.rand.Next(100) < CriticalRate);
                            int  NewDamage = Damage;
                            if (tg.OwnerPos > -1 && !MainMod.DisableDamageReductionByNumberOfCompanions)
                            {
                                float DamageMult = Main.player[tg.OwnerPos].GetModPlayer <PlayerMod>().DamageMod;
                                NewDamage = (int)(NewDamage * DamageMult);
                            }
                            HitSomething = true;
                            double result = Main.npc[n].StrikeNPC(NewDamage, Knockback, HitDirection, Critical);
                            if (result > 0)
                            {
                                if (SwordID == CaptainStenchBase.AmethystFalchion)
                                {
                                    if (Main.rand.NextDouble() < 0.4)
                                    {
                                        Main.npc[n].AddBuff(Terraria.ID.BuffID.ShadowFlame, 10 * 60);
                                    }
                                }
                                else if (SwordID == CaptainStenchBase.RubyFalchion)
                                {
                                    int HealthRecover = (int)(Math.Max(1, result * 0.05f));
                                    tg.RestoreHP(HealthRecover);
                                }
                                else if (SwordID == CaptainStenchBase.DiamondFalchion)
                                {
                                    if (Main.rand.NextDouble() < 0.5)
                                    {
                                        Main.npc[n].AddBuff(Terraria.ID.BuffID.Dazed, 3 * 60);
                                    }
                                }
                                Main.PlaySound(Main.npc[n].HitSound, Main.npc[n].Center);
                            }
                            tg.AddNpcHit(n);
                            tg.IncreaseDamageStacker((int)result, Main.npc[n].lifeMax);
                            if (result > 0)
                            {
                                if (tg.HasFlag(GuardianFlags.BeetleOffenseEffect))
                                {
                                    tg.IncreaseCooldownValue(GuardianCooldownManager.CooldownType.BeetleCounter, (int)result);
                                }
                                tg.OnHitSomething(Main.npc[n]);
                                tg.AddSkillProgress((float)result, GuardianSkills.SkillTypes.Strength); //(float)result
                                if (SwordID == CaptainStenchBase.AmethystFalchion)
                                {
                                    tg.AddSkillProgress((float)result * 0.15f, GuardianSkills.SkillTypes.Mysticism);
                                }
                                if (Critical)
                                {
                                    tg.AddSkillProgress((float)result, GuardianSkills.SkillTypes.Luck); //(float)result
                                }
                            }
                        }
                        else
                        {
                        }
                    }
                }

                if (HitSomething)
                {
                    if (SwordID == CaptainStenchBase.SapphireFalchion)
                    {
                        tg.ChangeSubAttackCooldown(CaptainStenchBase.GPSubAttack, -0.25f);
                        tg.MP += (int)(2 * tg.ManaHealMult);
                        if (tg.MP > tg.MMP)
                        {
                            tg.MP = tg.MMP;
                        }
                    }
                }
            }
            if (d.Step < 2)
            {
                if (d.Time >= 4)
                {
                    d.ChangeStep();
                }
            }
            else
            {
                if (d.Time >= 8)
                {
                    d.EndUse();
                }
            }
        }
예제 #4
0
        public override void Update(TerraGuardian tg, GuardianSpecialAttackData d)
        {
            if (d.FirstFrame)
            {
                if (d.Step == 5)
                {
                    CaptainStenchBase.CaptainStenchData data =
                        (CaptainStenchBase.CaptainStenchData)tg.Data;
                    Rectangle AttackHitbox = new Rectangle((int)(-32 * tg.Direction * tg.Scale) + (int)tg.Position.X, (int)(-102 * tg.Scale + tg.Position.Y), (int)(104 * tg.Scale), (int)(98 * tg.Scale));
                    if (tg.LookingLeft)
                    {
                        AttackHitbox.X -= AttackHitbox.Width;
                    }
                    int   Damage       = d.Damage;
                    int   CriticalRate = 4 + tg.MeleeCriticalRate;
                    float Knockback    = 8f;
                    byte  SwordID      = data.SwordID;
                    Main.PlaySound(2, tg.CenterPosition, 1);
                    if (SwordID > 0)
                    {
                        switch (SwordID)
                        {
                        case CaptainStenchBase.AmethystFalchion:
                        {
                            Vector2 SpawnPos = tg.PositionWithOffset;
                            float   Scale    = (float)tg.Height / 74 * tg.Scale * 1.5f;
                            SpawnPos.Y -= 39 * Scale;         //78
                            int p = Projectile.NewProjectile(SpawnPos, new Vector2(16f * tg.Direction, 0), Terraria.ModLoader.ModContent.ProjectileType <Projectiles.AmethystGP>(),
                                                             (int)(Damage * 1.333f), Knockback, tg.GetSomeoneToSpawnProjectileFor);
                            Main.PlaySound(2, tg.CenterPosition, 101);
                            Main.projectile[p].scale     = Scale;
                            Main.projectile[p].netUpdate = true;
                        }
                        break;

                        case CaptainStenchBase.TopazFalchion:
                        {
                            Knockback += 12f;
                            for (int s = 0; s < 4; s++)
                            {
                                Vector2 ShardSpawnPosition = tg.PositionWithOffset;
                                ShardSpawnPosition.X += Main.rand.Next((int)(tg.Width * -0.5f), (int)(tg.Width * 0.5f));
                                ShardSpawnPosition.Y -= Main.rand.Next(8, tg.Height - 8);
                                int p = Projectile.NewProjectile(ShardSpawnPosition, new Vector2(4f * tg.Direction, 0),
                                                                 Terraria.ModLoader.ModContent.ProjectileType <Projectiles.TopazGP>(), (int)(Damage * 0.25f), Knockback, tg.GetSomeoneToSpawnProjectileFor);
                                Main.projectile[p].scale     = tg.Scale;
                                Main.projectile[p].netUpdate = true;
                                Main.PlaySound(2, tg.CenterPosition, 101);
                            }
                        }
                        break;

                        case CaptainStenchBase.SapphireFalchion:
                        {
                            //Knockback *= 0.11f;
                            int p = Projectile.NewProjectile(tg.CenterPosition, new Vector2(8f * tg.Direction, 0), Terraria.ModLoader.ModContent.ProjectileType <Projectiles.SapphireGP>(),
                                                             Damage, Knockback, tg.GetSomeoneToSpawnProjectileFor);
                            Main.projectile[p].scale     = tg.Scale;
                            Main.projectile[p].netUpdate = true;
                            Main.PlaySound(2, tg.CenterPosition, 39);
                        }
                        break;

                        case CaptainStenchBase.EmeraldFalchion:
                        {
                            CriticalRate += 50;
                            Vector2 SpawnPosition = tg.PositionWithOffset;
                            SpawnPosition.Y -= 40 * tg.Scale * 1.5f;         //78
                            int p = Projectile.NewProjectile(SpawnPosition, new Vector2(1f * tg.Direction, 0), Terraria.ModLoader.ModContent.ProjectileType <Projectiles.EmeraldGP>(),
                                                             (int)(Damage * 0.75f), Knockback * 0.9f, tg.GetSomeoneToSpawnProjectileFor);
                            Main.projectile[p].scale     = tg.Scale * 1.5f;
                            Main.projectile[p].netUpdate = true;
                        }
                        break;

                        case CaptainStenchBase.DiamondFalchion:
                        {
                            Damage += (int)(tg.MHP * 0.05f);
                        }
                        break;
                        }
                    }
                    for (int n = 0; n < 200; n++)
                    {
                        if (Main.npc[n].active && !Main.npc[n].friendly && !tg.NpcHasBeenHit(n) && Main.npc[n].getRect().Intersects(AttackHitbox))
                        {
                            if (!Main.npc[n].dontTakeDamage)
                            {
                                int HitDirection = tg.Direction;
                                if ((HitDirection == -1 && tg.Position.X < Main.npc[n].Center.X) ||
                                    (HitDirection == 1 && tg.Position.X > Main.npc[n].Center.X))
                                {
                                    HitDirection *= -1;
                                }
                                bool Critical  = (Main.rand.Next(100) < CriticalRate);
                                int  NewDamage = Damage;
                                if (tg.OwnerPos > -1 && !MainMod.DisableDamageReductionByNumberOfCompanions)
                                {
                                    float DamageMult = Main.player[tg.OwnerPos].GetModPlayer <PlayerMod>().DamageMod;
                                    NewDamage = (int)(NewDamage * DamageMult);
                                }
                                double result = Main.npc[n].StrikeNPC(NewDamage, Knockback, HitDirection, Critical);
                                if (result > 0)
                                {
                                    if (SwordID == CaptainStenchBase.AmethystFalchion)
                                    {
                                        if (Main.rand.NextDouble() < 0.4)
                                        {
                                            Main.npc[n].AddBuff(Terraria.ID.BuffID.ShadowFlame, 10 * 60);
                                        }
                                    }
                                    else if (SwordID == CaptainStenchBase.RubyFalchion)
                                    {
                                        float     HealthRecover     = 0.1f;
                                        Rectangle SweetSpotPosition = new Rectangle((int)(tg.Position.X + tg.Direction * (48 + 40) * tg.Scale), (int)(tg.CenterY - 40 * tg.Scale), (int)(32 * tg.Scale), (int)(32 * tg.Scale));
                                        if (tg.LookingLeft)
                                        {
                                            SweetSpotPosition.X -= SweetSpotPosition.Width;
                                        }
                                        if (Main.npc[n].getRect().Intersects(SweetSpotPosition))
                                        {
                                            HealthRecover = 0.5f;
                                            Main.PlaySound(1, tg.CenterPosition);
                                            for (int i = 0; i < 25; i++)
                                            {
                                                Dust.NewDust(Main.npc[n].position, Main.npc[n].width, Main.npc[n].height, Terraria.ID.DustID.Blood);
                                            }
                                        }
                                        if (HealthRecover * result >= 1)
                                        {
                                            tg.RestoreHP((int)(HealthRecover * result));
                                        }
                                        else
                                        {
                                            tg.RestoreHP(1);
                                        }
                                        tg.AddBuff(Terraria.ModLoader.ModContent.BuffType <Buffs.DrainingHealth>(), 60);
                                    }
                                    else if (SwordID == CaptainStenchBase.DiamondFalchion)
                                    {
                                        Main.npc[n].AddBuff(Terraria.ID.BuffID.Confused, 3 * 60);
                                    }
                                }
                                Main.PlaySound(Main.npc[n].HitSound, Main.npc[n].Center);
                                tg.AddNpcHit(n);
                                tg.IncreaseDamageStacker((int)result, Main.npc[n].lifeMax);
                                if (result > 0)
                                {
                                    if (tg.HasFlag(GuardianFlags.BeetleOffenseEffect))
                                    {
                                        tg.IncreaseCooldownValue(GuardianCooldownManager.CooldownType.BeetleCounter, (int)result);
                                    }
                                    tg.OnHitSomething(Main.npc[n]);
                                    tg.AddSkillProgress((float)result, GuardianSkills.SkillTypes.Strength); //(float)result
                                    if (SwordID == CaptainStenchBase.AmethystFalchion)
                                    {
                                        tg.AddSkillProgress((float)result * 0.15f, GuardianSkills.SkillTypes.Mysticism);
                                    }
                                    if (Critical)
                                    {
                                        tg.AddSkillProgress((float)result, GuardianSkills.SkillTypes.Luck); //(float)result
                                    }
                                }
                            }
                            else
                            {
                            }
                        }
                    }
                }
            }
            if (d.Step < 10)
            {
                if (d.Time >= AnimationTime)
                {
                    d.ChangeStep();
                }
            }
            else
            {
                d.EndUse();
            }
        }
예제 #5
0
 public override void GuardianAnimationScript(TerraGuardian guardian, ref bool UsingLeftArm, ref bool UsingRightArm)
 {
     if (guardian.Velocity.Y != 0 && guardian.WallSlideStyle == 0 && guardian.DashCooldown <= 0 && !guardian.SittingOnPlayerMount && !guardian.KnockedOut && !guardian.Downed && guardian.BodyAnimationFrame != HeavySwingFrames[1] && guardian.BodyAnimationFrame != HeavySwingFrames[2] && (!guardian.Wet || !guardian.HasFlag(GuardianFlags.SwimmingAbility)))
     {
         if (guardian.Velocity.Y < -1.5f)
         {
             guardian.BodyAnimationFrame = 17;
         }
         else if (guardian.Velocity.Y < 1.5f)
         {
             guardian.BodyAnimationFrame = 18;
         }
         else
         {
             guardian.BodyAnimationFrame = 19;
         }
         if (!UsingLeftArm)
         {
             guardian.LeftArmAnimationFrame = guardian.BodyAnimationFrame;
         }
         if (!UsingRightArm)
         {
             guardian.RightArmAnimationFrame = guardian.BodyAnimationFrame;
         }
     }
 }
예제 #6
0
        //Pets and Summons backup

        /*public bool bunny, penguin, puppy, grinch, turtle, eater, skeletron, hornet, tiki, lizard, parrot, truffle, sapling, cSapling, spider, squashling, wisp, dino,
         *  babyFaceMonster, slime, eyeSpring, snowman, blackCat, zephyrfish, pygmy, spiderMinion, miniMinotaur;*/

        public PlayerDataBackup(Player player, TerraGuardian guardian)
        {
            this.player      = player;
            this.guardian    = guardian;
            Position         = player.position;
            Velocity         = player.velocity;
            Direction        = player.direction;
            ItemPosition     = player.itemLocation;
            Width            = player.width;
            Height           = player.height;
            numMinions       = player.numMinions;
            maxMinions       = player.maxMinions;
            SlotsMinion      = player.slotsMinions;
            Wet              = player.wet;
            Active           = player.active;
            MouseX           = Main.mouseX;
            MouseY           = Main.mouseY;
            Dead             = player.dead;
            FrostBurn        = player.frostArmor;
            MeleeEnchantment = player.meleeEnchant;
            ItemAnimation    = player.itemAnimation;
            ItemAnimationMax = player.itemAnimationMax;
            ItemTime         = player.itemTime;
            ItemRotation     = player.itemRotation;
            HeldProj         = player.heldProj;
            channel          = player.channel;
            townNPCs         = player.townNPCs;
            activeNPCs       = player.activeNPCs;
            Zone1            = player.zone1;
            Zone2            = player.zone2;
            Zone3            = player.zone3;
            Zone4            = player.zone4;
            BuffTypes        = (int[])player.buffType.Clone();
            BuffTimes        = (int[])player.buffTime.Clone();
            ghostHeal        = player.ghostHeal;
            ghostHurt        = player.ghostHurt;
            LifeStealRate    = player.lifeSteal;
            GhostDamage      = player.ghostDmg;

            phantasmTime = player.phantasmTime;

            //BackupPetSummonData(player, guardian);

            player.position     = guardian.TopLeftPosition;
            player.velocity     = guardian.Velocity;
            player.direction    = guardian.Direction;
            player.width        = guardian.Width;
            player.height       = guardian.Height;
            player.itemLocation = new Vector2(guardian.ItemPositionX, guardian.ItemPositionY) + guardian.Position;
            //player.numMinions = guardian.NumMinions + player.maxMinions;
            //player.maxMinions += guardian.MaxMinions;
            //player.slotsMinions = guardian.MinionSlotCount;
            player.wet    = guardian.Wet;
            player.active = guardian.Active;
            player.dead   = guardian.Downed;
            Main.mouseX  += (int)guardian.AimDirection.X - (Main.mouseX + (int)Main.screenPosition.X);
            Main.mouseY  += (int)guardian.AimDirection.Y - (Main.mouseY + (int)Main.screenPosition.Y);
            if (guardian.GravityDirection < 0)
            {
                Main.mouseY += (int)(guardian.AimDirection.Y - guardian.CenterY) * 2;
            }
            player.frostArmor       = guardian.HasFlag(GuardianFlags.FrostSetEffect);
            player.meleeEnchant     = guardian.MeleeEnchant;
            player.itemAnimation    = guardian.ItemAnimationTime;
            player.itemAnimationMax = guardian.ItemMaxAnimationTime;
            player.itemTime         = guardian.ItemUseTime;
            player.itemRotation     = guardian.ItemRotation;
            player.heldProj         = guardian.HeldProj;
            //player.townNPCs = guardian.TownNpcs;
            player.activeNPCs = guardian.ActiveNpcs;
            player.channel    = guardian.Channeling;

            player.phantasmTime = guardian.GetCooldownValue(GuardianCooldownManager.CooldownType.PhantasmCooldown);

            player.zone1 = guardian.Zone1;
            player.zone2 = guardian.Zone2;
            player.zone3 = guardian.Zone3;
            player.zone4 = guardian.Zone4;

            player.ghostHeal = guardian.HasFlag(GuardianFlags.SpectreHealSetEffect);
            player.ghostHurt = guardian.HasFlag(GuardianFlags.SpectreSplashSetEffect);
            player.lifeSteal = guardian.LifeStealRate;
            player.ghostDmg  = guardian.GhostDamage;
        }
예제 #7
0
        public override void UpdateAnimation(TerraGuardian guardian, ref bool UsingLeftArmAnimation, ref bool UsingRightArmAnimation)
        {
            if ((guardian.Base.DuckingFrame == -1 && guardian.Base.ReviveFrame == -1) || guardian.ItemAnimationTime > 0)
            {
                return;
            }
            Vector2 TargetPosition = Vector2.Zero;
            int     TargetWidth = 0, TargetHeight = 0;
            bool    IsMounted = false, TargetIsBeingCarried = false;
            int     TargetLayer = 0;

            if (TargetIsPlayer)
            {
                TargetLayer          = RevivePlayer.GetModPlayer <PlayerMod>().MyDrawOrderID;
                TargetPosition       = RevivePlayer.position;
                TargetWidth          = RevivePlayer.width;
                TargetHeight         = RevivePlayer.height;
                TargetIsBeingCarried = RevivePlayer.GetModPlayer <PlayerMod>().BeingCarriedByGuardian;
                if ((guardian.OwnerPos != RevivePlayer.whoAmI || (guardian.OwnerPos == RevivePlayer.whoAmI && !guardian.PlayerMounted)) && RevivePlayer.GetModPlayer <PlayerMod>().MountedOnGuardian)
                {
                    IsMounted = true;
                }
            }
            else
            {
                TargetLayer          = ReviveGuardian.MyDrawOrder;
                TargetPosition       = ReviveGuardian.TopLeftPosition;
                TargetWidth          = ReviveGuardian.Width;
                TargetHeight         = ReviveGuardian.Height;
                TargetIsBeingCarried = ReviveGuardian.BeingCarriedByGuardian;
                if (ReviveGuardian.OwnerPos > -1 && ReviveGuardian.PlayerControl && Main.player[ReviveGuardian.OwnerPos].GetModPlayer <PlayerMod>().MountedOnGuardian)
                {
                    IsMounted = true;
                }
            }
            //What to do if the target is above dangerous tiles, like Spikes? How will they rescue that character?
            if (new Rectangle((int)TargetPosition.X, (int)TargetPosition.Y, TargetWidth, TargetHeight).Intersects(guardian.HitBox))
            {
                bool IsStopped = guardian.Velocity.X == 0 || guardian.HasFlag(GuardianFlags.WindPushed);
                if (guardian.Velocity.X == 0 || guardian.HasFlag(GuardianFlags.WindPushed))
                {
                    if (guardian.BodyAnimationFrame == guardian.Base.StandingFrame ||
                        guardian.BodyAnimationFrame == guardian.Base.BackwardStanding)
                    {
                        int Animation    = guardian.Base.StandingFrame;
                        int ArmAnimation = -1;
                        if (IsMounted || TargetIsBeingCarried)
                        {
                            ArmAnimation = guardian.Base.ItemUseFrames[2];
                        }
                        else
                        {
                            if (MainMod.ShowBackwardAnimations && TargetLayer < guardian.MyDrawOrder && guardian.Base.BackwardRevive > -1)
                            {
                                Animation = guardian.Base.BackwardRevive;
                            }
                            else if (guardian.Base.ReviveFrame > -1)
                            {
                                Animation = guardian.Base.ReviveFrame;
                            }
                            else if (guardian.Base.DuckingFrame > -1)
                            {
                                Animation    = guardian.Base.DuckingFrame;
                                ArmAnimation = guardian.Base.DuckingSwingFrames[2];
                            }
                        }
                        if (ArmAnimation == -1)
                        {
                            ArmAnimation = Animation;
                        }
                        guardian.BodyAnimationFrame     = Animation;
                        guardian.RightArmAnimationFrame = guardian.LeftArmAnimationFrame = ArmAnimation;
                        UsingRightArmAnimation          = UsingLeftArmAnimation = true;
                    }
                }
            }
        }
예제 #8
0
 public override void Update(TerraGuardian tg, GuardianSpecialAttackData data)
 {
     tg.Velocity = Vector2.Zero;
     if (data.Step >= 4)
     {
         tg.TrailDelay    = 2;
         tg.TrailLength   = 10;
         tg.ImmuneTime    = 30;
         tg.ImmuneNoBlink = true;
         Vector2 Velocity = Collision.TileCollision(tg.TopLeftPosition, new Vector2(tg.Direction * 20, 0), tg.CollisionWidth, tg.CollisionHeight);
         tg.Position += Velocity;
         tg.Velocity  = Vector2.Zero;
         if (Collision.SolidCollision(tg.TopLeftPosition, tg.CollisionWidth, tg.CollisionHeight))
         {
             if (tg.LookingLeft)
             {
                 tg.Position.X = (int)(tg.Position.X * 0.0625f) * 16 + 16 + tg.CollisionWidth * 0.5f;
             }
             else
             {
                 tg.Position.X = (int)(tg.Position.X * 0.0625f) * 16 + tg.CollisionWidth - tg.CollisionWidth * 0.5f;
             }
         }
         Rectangle rect         = tg.HitBox;
         int       Damage       = data.Damage;
         float     Knockback    = 1.5f;
         int       CriticalRate = 65 + tg.MeleeCriticalRate;
         int       SwordID      = (tg.Data as CaptainStenchBase.CaptainStenchData).SwordID;
         for (int n = 0; n < 200; n++)
         {
             if (Main.npc[n].active && !Main.npc[n].friendly && !tg.NpcHasBeenHit(n) && Main.npc[n].getRect().Intersects(rect))
             {
                 if (!Main.npc[n].dontTakeDamage)
                 {
                     int HitDirection = tg.Direction;
                     if ((HitDirection == -1 && tg.Position.X < Main.npc[n].Center.X) ||
                         (HitDirection == 1 && tg.Position.X > Main.npc[n].Center.X))
                     {
                         HitDirection *= -1;
                     }
                     bool Critical  = (Main.rand.Next(100) < CriticalRate);
                     int  NewDamage = Damage;
                     if (tg.OwnerPos > -1 && !MainMod.DisableDamageReductionByNumberOfCompanions)
                     {
                         float DamageMult = Main.player[tg.OwnerPos].GetModPlayer <PlayerMod>().DamageMod;
                         NewDamage = (int)(NewDamage * DamageMult);
                     }
                     double result = Main.npc[n].StrikeNPC(NewDamage, Knockback, HitDirection, Critical);
                     if (result > 0)
                     {
                         if (SwordID == CaptainStenchBase.AmethystFalchion)
                         {
                             if (Main.rand.NextDouble() < 0.4)
                             {
                                 Main.npc[n].AddBuff(Terraria.ID.BuffID.ShadowFlame, 10 * 60);
                             }
                         }
                         else if (SwordID == CaptainStenchBase.RubyFalchion)
                         {
                             int HealthRecover = (int)(Math.Max(1, result * 0.05f));
                             tg.RestoreHP(HealthRecover);
                         }
                         else if (SwordID == CaptainStenchBase.DiamondFalchion)
                         {
                             Main.npc[n].AddBuff(Terraria.ID.BuffID.Confused, 3 * 60);
                         }
                     }
                     Main.PlaySound(Main.npc[n].HitSound, Main.npc[n].Center);
                     tg.AddNpcHit(n);
                     tg.IncreaseDamageStacker((int)result, Main.npc[n].lifeMax);
                     if (result > 0)
                     {
                         if (tg.HasFlag(GuardianFlags.BeetleOffenseEffect))
                         {
                             tg.IncreaseCooldownValue(GuardianCooldownManager.CooldownType.BeetleCounter, (int)result);
                         }
                         tg.OnHitSomething(Main.npc[n]);
                         tg.AddSkillProgress((float)result, GuardianSkills.SkillTypes.Strength); //(float)result
                         if (SwordID == CaptainStenchBase.AmethystFalchion)
                         {
                             tg.AddSkillProgress((float)result * 0.15f, GuardianSkills.SkillTypes.Mysticism);
                         }
                         if (Critical)
                         {
                             tg.AddSkillProgress((float)result, GuardianSkills.SkillTypes.Luck); //(float)result
                         }
                     }
                 }
             }
         }
     }
     if (data.Time >= 3)
     {
         if (data.Step < 10)
         {
             data.ChangeStep();
         }
         else
         {
             data.EndUse();
         }
     }
 }