Example #1
0
 public PvPProjectile(int type, int index, int ownerIndex, PvPItem item)
 {
     SetDefaults(type);
     identity        = index;
     ItemOriginated  = item;
     owner           = ownerIndex;
     OwnerProjectile = PvPModifier.PvPers[ownerIndex];
 }
Example #2
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)
             {
                 SetBuff(Cache.Buffs[buffType].InflictBuff);
             }
             continue;
         }
         SetBuff(Cache.Buffs[buffType].InflictBuff);
     }
 }
Example #3
0
        /// <summary>
        /// Applies nebula, spectre, and frost armor effects.
        /// </summary>
        public void ApplyArmorEffects(PvPPlayer target, PvPItem weapon, PvPProjectile projectile)
        {
            if (TPlayer.setNebula && TPlayer.nebulaCD == 0 && Main.rand.Next(3) == 0 && PvPModifier.Config.EnableNebula && weapon.magic)
            {
                TPlayer.nebulaCD = 30;
                int type = Terraria.Utils.SelectRandom(Main.rand, 3453, 3454, 3455);

                int index = Item.NewItem((int)TPlayer.position.X, (int)TPlayer.position.Y, TPlayer.width, TPlayer.height, type);

                float velocityY = Main.rand.Next(-20, 1) * 0.2f;
                float velocityX = Main.rand.Next(10, 31) * 0.2f * Main.rand.Next(-1, 1).Replace(0, 1);

                var itemDrop = new PacketWriter()
                               .SetType((int)PacketTypes.UpdateItemDrop)
                               .PackInt16((short)index)
                               .PackSingle(target.TPlayer.position.X)
                               .PackSingle(target.TPlayer.position.Y)
                               .PackSingle(velocityX)
                               .PackSingle(velocityY)
                               .PackInt16(1)
                               .PackByte(0)
                               .PackByte(0)
                               .PackInt16((short)type)
                               .GetByteData();
                var itemOwner = new PacketWriter()
                                .SetType((int)PacketTypes.ItemOwner)
                                .PackInt16((short)index)
                                .PackByte((byte)Index)
                                .GetByteData();

                foreach (var pvper in PvPModifier.ActivePlayers)
                {
                    pvper.SendRawData(itemDrop);
                    pvper.SendRawData(itemOwner);
                }
            }

            if ((weapon.ranged || weapon.melee) && TPlayer.frostArmor && PvPModifier.Config.EnableFrost)
            {
                target.SetBuff(44, (int)(PvPModifier.Config.FrostDuration * 30));
            }

            if (TPlayer.ghostHurt && projectile?.type != 356)
            {
                TerrariaUtils.ActivateSpectreBolt(this, target, weapon, weapon.ConfigDamage);
            }
        }
Example #4
0
        /// <summary>
        /// Applies turtle and thorns damage to the attacker.
        /// </summary>
        public void ApplyReflectDamage(PvPPlayer attacker, int damage, PvPItem weapon)
        {
            PvPItem reflectTag   = new PvPItem(1150);
            Random  random       = new Random();
            string  deathmessage = PresetData.ReflectedDeathMessages[random.Next(PresetData.ReflectedDeathMessages.Count)];

            if (PvPModifier.Config.EnableTurtle && attacker.TPlayer.setBonus == Language.GetTextValue("ArmorSetBonus.Turtle") && weapon.melee)
            {
                deathmessage = Name + deathmessage + attacker.Name + "'s Turtle Armor.";
                int turtleDamage = (int)(damage * PvPModifier.Config.TurtleMultiplier);

                NetMessage.SendPlayerHurt(this.Index, PlayerDeathReason.ByCustomReason(PvPUtils.GetPvPDeathMessage(deathmessage, reflectTag, type: 2)),
                                          turtleDamage, 0, false, true, 5);
            }

            if (PvPModifier.Config.EnableThorns && attacker.TPlayer.FindBuffIndex(14) != -1)
            {
                int thornDamage = (int)(damage * PvPModifier.Config.ThornMultiplier);
                deathmessage = Name + deathmessage + attacker.Name + "'s Thorns.";

                NetMessage.SendPlayerHurt(this.Index, PlayerDeathReason.ByCustomReason(PvPUtils.GetPvPDeathMessage(deathmessage, reflectTag, type: 2)),
                                          thornDamage, 0, false, true, 5);
            }
        }
Example #5
0
 /// <summary>
 /// Damages players. Criticals and custom knockback will apply if enabled.
 /// </summary>
 public void DamagePlayer(string deathmessage, PvPItem weapon, int damage, int hitDirection, bool isCrit)
 {
     NetMessage.SendPlayerHurt(this.Index, PlayerDeathReason.ByCustomReason(deathmessage),
                               damage, hitDirection, false, true, 5);
 }
Example #6
0
        public void InsertProjectile(int index, int projectileType, int ownerIndex, PvPItem item)
        {
            var projectile = new PvPProjectile(projectileType, index, ownerIndex, item);

            Projectiles[projectileType] = projectile;
        }
Example #7
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, projectile);
     TerrariaUtils.ActivateYoyoBag(this, attacker, damage, weapon.knockBack);
 }