示例#1
0
        /// <summary>
        /// Gets the first available ammo for a weapon.
        /// </summary>
        /// <param Name="weapon">The weapon to find ammo for.</param>
        /// <returns></returns>
        public PvPItem GetFirstAvailableAmmo(PvPItem weapon)
        {
            int useAmmo = weapon.useAmmo;

            if (useAmmo == AmmoID.None)
            {
                return(new PvPItem());
            }

            for (int x = 54; x < NetItem.InventorySlots; x++)
            {
                if (this.TPlayer.inventory[x].ammo == useAmmo)
                {
                    return(PvPUtils.ConvertToPvPItem(this.TPlayer.inventory[x]));
                }
            }

            for (int x = 0; x < NetItem.InventorySlots - 4; x++)
            {
                if (this.TPlayer.inventory[x].ammo == useAmmo)
                {
                    return(PvPUtils.ConvertToPvPItem(this.TPlayer.inventory[x]));
                }
            }

            return(new PvPItem());
        }
示例#2
0
 public void InsertProjectile(int index, int projectileType, int ownerIndex, PvPItem item)
 {
     Projectiles[projectileType] = new PvPProjectile(projectileType)
     {
         identity        = index,
         ItemOriginated  = item,
         owner           = ownerIndex,
         OwnerProjectile = PvPController.PvPers[ownerIndex]
     };
 }
示例#3
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);
        }
示例#4
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);
        }
示例#5
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));
            }
        }
示例#6
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));
     }
 }
示例#7
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);
            }
        }
示例#8
0
        /// <summary>
        /// Gets the critical percentage of an item.
        /// Note: The ranged crit value is the final crit value, whereas the other crits have to
        /// be added to the existing weapon crit value.
        /// </summary>
        public int GetCrit(PvPItem weapon)
        {
            int crit = weapon.crit;

            if (weapon.melee)
            {
                crit += TPlayer.meleeCrit;
            }
            else if (weapon.ranged)
            {
                crit = TPlayer.rangedCrit;
            }
            else if (weapon.magic)
            {
                crit += TPlayer.magicCrit;
            }
            else if (weapon.thrown)
            {
                crit += TPlayer.thrownCrit;
            }

            return(crit);
        }
示例#9
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);
 }