Example #1
0
        /// <summary>
        /// Damages players. Criticals and custom knockback will apply if enabled.
        /// </summary>
        public void DamagePlayer(PvPPlayer attacker, PvPItem weapon, int damage, int hitDirection, bool isCrit)
        {
            damage *= isCrit ? 2 : 1;
            string star  = isCrit ? "!!" : "*";
            var    color = isCrit ? Color.SlateBlue : Color.DarkTurquoise;

            NetMessage.SendPlayerHurt(this.Index, PlayerDeathReason.ByCustomReason(PvPUtils.GetPvPDeathMessage(attacker, this, weapon)),
                                      damage, hitDirection, false, true, 5);
            Interface.PlayerTextPopup(attacker, this, star + TerrariaUtils.GetHurtDamage(this, damage) + star, color);
        }
Example #2
0
        /// <summary>
        /// Gets the damage dealt to a person with server side calculations.
        /// </summary>
        public int GetDamageDealt(PvPPlayer attacker, PvPItem weapon, PvPProjectile projectile = null)
        {
            int damage = (projectile == null || projectile.GetConfigDamage() < 1)
                ? weapon.GetPvPDamage(attacker)
                : projectile.GetConfigDamage();

            damage += PvPUtils.GetAmmoDamage(attacker, weapon);
            damage += PvPUtils.GenerateDamageVariance();
            damage += PvPUtils.GetVortexDamage(attacker, weapon, damage);

            damage -= (int)(GetDefenseDifferenceFromModded() * 0.5);

            return(damage);
        }
Example #3
0
        /// <summary>
        /// Applies nebula and frost armor effects.
        /// </summary>
        public void ApplyArmorEffects(PvPPlayer attacker, PvPItem weapon)
        {
            if (weapon.magic &&
                attacker.TPlayer.armor[0].netID == 2760 && attacker.TPlayer.armor[1].netID == 2761 && attacker.TPlayer.armor[2].netID == 2762 &&
                PvPController.Config.EnableNebula)
            {
                if (attacker.TPlayer.FindBuffIndex(181) != -1 && PvPController.Config.NebulaTier3Duration != 0)
                {
                    attacker.SetBuff(175, (int)(PvPController.Config.NebulaTier3Duration * 60));
                    attacker.SetBuff(178, (int)(PvPController.Config.NebulaTier3Duration * 60));
                    attacker.SetBuff(181, (int)(PvPController.Config.NebulaTier3Duration * 60));
                }
                else if (attacker.TPlayer.FindBuffIndex(180) != -1 && PvPController.Config.NebulaTier3Duration != 0)
                {
                    attacker.SetBuff(175, 1);
                    attacker.SetBuff(178, 1);
                    attacker.SetBuff(181, 1);
                    Task.Delay(100).ContinueWith(t => {
                        attacker.SetBuff(175, (int)(PvPController.Config.NebulaTier3Duration * 60));
                        attacker.SetBuff(178, (int)(PvPController.Config.NebulaTier3Duration * 60));
                        attacker.SetBuff(181, (int)(PvPController.Config.NebulaTier3Duration * 60));
                    });
                }
                else if (attacker.TPlayer.FindBuffIndex(179) != -1 && PvPController.Config.NebulaTier2Duration != 0)
                {
                    attacker.SetBuff(174, 1);
                    attacker.SetBuff(177, 1);
                    attacker.SetBuff(180, 1);
                    Task.Delay(100).ContinueWith(t => {
                        attacker.SetBuff(174, (int)(PvPController.Config.NebulaTier2Duration * 60));
                        attacker.SetBuff(177, (int)(PvPController.Config.NebulaTier2Duration * 60));
                        attacker.SetBuff(180, (int)(PvPController.Config.NebulaTier2Duration * 60));
                    });
                }
                else
                {
                    attacker.SetBuff(173, (int)(PvPController.Config.NebulaTier1Duration * 60));
                    attacker.SetBuff(176, (int)(PvPController.Config.NebulaTier1Duration * 60));
                    attacker.SetBuff(179, (int)(PvPController.Config.NebulaTier1Duration * 60));
                }
            }

            if ((weapon.ranged || weapon.melee) &&
                attacker.TPlayer.armor[0].netID == 684 && attacker.TPlayer.armor[1].netID == 685 && attacker.TPlayer.armor[2].netID == 686 &&
                PvPController.Config.EnableFrost)
            {
                this.SetBuff(44, (int)(PvPController.Config.FrostDuration * 30));
            }
        }
Example #4
0
 /// <summary>
 /// Applies buffs to the attacker based off own buffs, if any.
 /// </summary>
 public void ApplyBuffDebuffs(PvPPlayer attacker, PvPItem weapon)
 {
     for (int x = 0; x < Terraria.Player.maxBuffs; x++)
     {
         int buffType = attacker.TPlayer.buffType[x];
         if (PresetData.FlaskDebuffs.ContainsKey(buffType))
         {
             if (weapon.melee)
             {
                 this.SetBuff(Database.GetBuffInfo(DbConsts.BuffTable, buffType, true));
             }
             continue;
         }
         this.SetBuff(Database.GetBuffInfo(DbConsts.BuffTable, buffType, true));
     }
 }
Example #5
0
        /// <summary>
        /// Applies turtle and thorns damage to the attacker.
        /// </summary>
        public void ApplyReflectDamage(PvPPlayer attacker, int damage, PvPItem weapon)
        {
            PvPItem reflectType = new PvPItem();

            if (PvPController.Config.EnableTurtle && this.TPlayer.setBonus == Language.GetTextValue("ArmorSetBonus.Turtle") && weapon.melee)
            {
                reflectType.SpecialName = "Turtle Armor";
                int turtleDamage = (int)(damage * PvPController.Config.TurtleMultiplier);

                NetMessage.SendPlayerHurt(attacker.Index, PlayerDeathReason.ByCustomReason(PvPUtils.GetPvPDeathMessage(this, attacker, reflectType, 2)),
                                          turtleDamage, 0, false, true, 5);
            }

            if (PvPController.Config.EnableThorns && this.TPlayer.FindBuffIndex(14) != -1)
            {
                reflectType.SpecialName = "Thorns";
                int thornDamage = (int)(damage * PvPController.Config.ThornMultiplier);

                NetMessage.SendPlayerHurt(attacker.Index, PlayerDeathReason.ByCustomReason(PvPUtils.GetPvPDeathMessage(this, attacker, reflectType, 2)),
                                          thornDamage, 0, false, true, 5);
            }
        }
Example #6
0
 /// <summary>
 /// Gets the knockback of an item.
 /// </summary>
 /// <param Name="owner"></param>
 /// <returns></returns>
 public float GetKnockback(PvPPlayer owner) =>
 owner.TPlayer.GetWeaponKnockback(this, Database.GetData <float>(DbConsts.ItemTable, type, DbConsts.Knockback));
Example #7
0
 /// <summary>
 /// Gets raw damage based off Terraria damage calculations.
 /// </summary>
 /// <param Name="owner"></param>
 /// <returns></returns>
 public int GetPvPDamage(PvPPlayer owner) => TerrariaUtils.GetWeaponDamage(owner, this);
Example #8
0
 /// <summary>
 /// Applies effects that normally won't work in vanilla pvp.
 /// Effects include nebula/frost armor, yoyo-bag projectiles, and thorns/turtle damage.
 /// </summary>
 public void ApplyPvPEffects(PvPPlayer attacker, PvPItem weapon, PvPProjectile projectile, int damage)
 {
     this.ApplyReflectDamage(attacker, damage, weapon);
     this.ApplyArmorEffects(attacker, weapon);
     TerrariaUtils.ActivateYoyo(attacker, this, damage, weapon.knockBack);
 }