Пример #1
0
        /// <summary>
        /// Generates a death message for a person based off the weapon and type of death.
        /// </summary>
        /// <param name="type">1 for normal hits, 2 for reflection hits such as thorns and turtle.</param>
        public static string GetPvPDeathMessage(string deathMessage, PvPItem weapon, PvPProjectile proj = null, int type = 1)
        {
            string tag = "";

            if (type == 1)
            {
                tag = weapon?.netID != 0 || proj?.ItemOriginated?.netID != 0 ?
                      "[i/p{0}:{1}] ".SFormat(proj?.ItemOriginated?.prefix ?? weapon?.prefix,
                                              proj?.ItemOriginated?.netID ?? weapon?.netID)
                : "";
            }
            else if (type == 2)
            {
                tag = "[i:1150] ";
            }

            return(tag + deathMessage);
        }
Пример #2
0
        /// <summary>
        /// Displays the stats of a player and weapon on the right side of their screen.
        /// Stats include damage, projectile, debuffs and buffs, knockback, criticals, and defense.
        /// </summary>
        /// <param Name="player"></param>
        public static void DisplayInterface(PvPPlayer player)
        {
            StringBuilder sb = new StringBuilder();

            PvPItem       weapon     = player.GetPlayerItem;
            PvPProjectile projectile = weapon.useAmmo == AmmoID.None
                ? player.GetPlayerItem.GetItemShoot
                : weapon.GetItemShoot.type > 0
                    ? weapon.GetItemShoot
                    : player.GetFirstAvailableAmmo(weapon).GetItemShoot;

            sb.AppendLine(MiscUtils.LineBreaks(8));
            sb.AppendLine("Weapon and Armor Stats (/toggletooltip or /tt)");
            sb.AppendLine(new string('-', 40));

            if (weapon.GetPvPDamage(player) > 0 && weapon.netID != 0)
            {
                sb.AppendLine(weapon.Name + ": " + weapon.GetPvPDamage(player) + " damage");
            }

            if (PvPController.Config.EnableWeaponDebuffs)
            {
                if (weapon.GetDebuffInfo.BuffId != 0)
                {
                    sb.AppendLine("  Inflicts {0} for {1}s."
                                  .SFormat(Lang.GetBuffName(weapon.GetDebuffInfo.BuffId), weapon.GetDebuffInfo.BuffDuration / 60.0));
                }
            }

            if (PvPController.Config.EnableWeaponSelfBuffs)
            {
                if (weapon.GetSelfBuffInfo.BuffId != 0)
                {
                    sb.AppendLine("  Inflicts {0} to self for {1}s."
                                  .SFormat(Lang.GetBuffName(weapon.GetSelfBuffInfo.BuffId), weapon.GetSelfBuffInfo.BuffDuration / 60.0));
                }
            }

            if (projectile.type > 0)
            {
                int shoot = projectile.type;
                sb.AppendLine("  Shoots " + Lang.GetProjectileName(shoot));

                if (PvPController.Config.EnableProjectileDebuffs)
                {
                    if (projectile.GetDebuffInfo().BuffId != 0)
                    {
                        sb.AppendLine("    Inflicts {0} for {1}s."
                                      .SFormat(Lang.GetBuffName(projectile.GetDebuffInfo().BuffId), projectile.GetDebuffInfo().BuffDuration / 60.0));
                    }
                }

                if (PvPController.Config.EnableProjectileSelfBuffs)
                {
                    if (projectile.GetSelfBuffInfo().BuffId != 0)
                    {
                        sb.AppendLine("    Inflicts {0} to self for {1}s."
                                      .SFormat(Lang.GetBuffName(projectile.GetSelfBuffInfo().BuffId), projectile.GetSelfBuffInfo().BuffDuration / 60.0));
                    }
                }
            }

            for (int x = 0; x < Player.maxBuffs; x++)
            {
                int buffType     = player.TPlayer.buffType[x];
                var debuffInfo   = Database.GetBuffInfo(DbConsts.BuffTable, x, true);
                var selfBuffInfo = Database.GetBuffInfo(DbConsts.BuffTable, x, false);

                if (PvPController.Config.EnableBuffDebuff)
                {
                    if (debuffInfo.BuffId != 0)
                    {
                        sb.AppendLine("Buff {0} applies {1} ({2}s) to weapons."
                                      .SFormat(Lang.GetBuffName(buffType), Lang.GetBuffName(debuffInfo.BuffId), debuffInfo.BuffDuration / 60.0).SeparateToLines());
                    }
                }

                if (PvPController.Config.EnableBuffSelfBuff)
                {
                    if (selfBuffInfo.BuffId != 0)
                    {
                        sb.AppendLine("Buff {0} applies {1} to self for {2}s on attack."
                                      .SFormat(Lang.GetBuffName(buffType), Lang.GetBuffName(selfBuffInfo.BuffId), selfBuffInfo.BuffDuration / 60.0).SeparateToLines());
                    }
                }
            }

            if (PvPController.Config.EnableKnockback)
            {
                sb.AppendLine("Knockback: " + player.GetPlayerItem.GetKnockback(player));
            }

            if (PvPController.Config.EnableCriticals)
            {
                if (player.GetCrit(weapon) > 0)
                {
                    sb.AppendLine("Critical: " + player.GetCrit(weapon) + "%");
                }
            }

            sb.AppendLine("Defense: " + player.GetPlayerDefense());
            sb.AppendLine(MiscUtils.LineBreaks(50));

            player.SendData(PacketTypes.Status, sb.ToString());
        }
Пример #3
0
        private void GetData(GetDataEventArgs args)
        {
            MemoryStream data     = new MemoryStream(args.Msg.readBuffer, args.Index, args.Length);
            PvPPlayer    attacker = pvpers[args.Msg.whoAmI];

            if (attacker == null || !attacker.TPlayer.active || !attacker.ConnectionAlive)
            {
                return;
            }
            if (!attacker.TPlayer.hostile)
            {
                return;
            }

            switch (args.MsgID)
            {
            case PacketTypes.PlayerHurtV2:
                PvPPlayer         target          = pvpers[data.ReadByte()];
                PlayerDeathReason playerHitReason = PlayerDeathReason.FromReader(new BinaryReader(data));
                if (target == null || !target.ConnectionAlive || !target.Active)
                {
                    return;
                }
                if (playerHitReason.SourcePlayerIndex == -1)
                {
                    target.lastHitBy = null;
                    return;
                }

                PvPProjectile projectile = playerHitReason.SourceProjectileIndex == -1 ? null : projectiles[playerHitReason.SourceProjectileIndex];
                PvPItem       weapon     = projectile == null?attacker.GetPlayerItem() : projectile.itemOriginated;

                int inflictedDamage = PvPController.config.enableDamageChanges ? target.GetDamageDealt(attacker, weapon, projectile) : data.ReadByte();
                int damageReceived  = target.GetDamageReceived(inflictedDamage);
                data.ReadByte(); data.ReadByte();
                int knockback = data.ReadByte() - 1;

                target.lastHitBy         = attacker;
                target.lastHitWeapon     = weapon;
                target.lastHitProjectile = projectile;

                DataHandler.OnPlayerHurtted(args, attacker, target, weapon, projectile, playerHitReason,
                                            inflictedDamage, damageReceived, knockback);

                break;

            case PacketTypes.TogglePvp:
                DataHandler.OnPvPToggled(attacker);
                break;

            case PacketTypes.PlayerSlot:
                data.ReadByte();
                int slot = data.ReadByte();
                DataHandler.OnPlayerSlotUpdated(attacker, slot);
                break;

            case PacketTypes.PlayerDeathV2:
                DataHandler.OnPlayerDead(attacker);
                break;

            case PacketTypes.ProjectileDestroy:
                DataHandler.OnProjectileDestroyed(data);
                break;

            case PacketTypes.PlayerUpdate:
                DataHandler.OnPlayerUpdated(data, attacker);
                break;
            }
        }
Пример #4
0
 public static void OnPlayerHurtted(GetDataEventArgs args, PvPPlayer attacker, PvPPlayer target, PvPItem weapon, PvPProjectile projectile,
                                    PlayerDeathReason playerHitReason, int inflictedDamage, int damageReceived, int knockback)
 {
     if (PlayerHurtted != null)
     {
         PlayerHurtted(typeof(DataHandler), new PlayerHurtArgs(args, attacker, target, weapon, projectile, playerHitReason, inflictedDamage, damageReceived, knockback));
     }
 }
Пример #5
0
 public PlayerHurtArgs(GetDataEventArgs args, PvPPlayer attacker, PvPPlayer target, PvPItem weapon, PvPProjectile projectile,
                       PlayerDeathReason playerHitReason, int inflictedDamage, int damageReceived, int knockback)
 {
     this.args            = args;
     this.attacker        = attacker;
     this.target          = target;
     this.weapon          = weapon;
     this.projectile      = projectile;
     this.playerHitReason = playerHitReason;
     this.inflictedDamage = inflictedDamage;
     this.damageReceived  = damageReceived;
     this.knockback       = knockback;
 }