public PlayerHurtArgs(GetDataEventArgs args, MemoryStream data, PvPPlayer attacker) { Args = args; var target = PvPController.PvPers[data.ReadByte()]; var playerHitReason = PlayerDeathReason.FromReader(new BinaryReader(data)); if (target == null || !target.ConnectionAlive || !target.Active) { IsPvPDamage = false; return; } if (playerHitReason.SourcePlayerIndex == -1) { IsPvPDamage = false; target.LastHitBy = null; return; } Projectile = playerHitReason.SourceProjectileIndex == -1 ? null : attacker.ProjTracker.Projectiles[playerHitReason.SourceProjectileType]; int int1 = data.ReadInt16(); //damage int int2 = data.ReadByte(); //knockback target.LastHitBy = attacker; target.LastHitWeapon = Weapon; target.LastHitProjectile = Projectile; Attacker = attacker; Target = target; Weapon = Projectile == null ? attacker.GetPlayerItem : Projectile.ItemOriginated; InflictedDamage = PvPController.Config.EnableDamageChanges ? target.GetDamageDealt(attacker, Weapon, Projectile) : int1; DamageReceived = target.GetDamageReceived(InflictedDamage); HitDirection = int2 - 1; Crit = attacker.GetCrit(Weapon); PlayerHitReason = playerHitReason; IsPvPDamage = true; }
/// <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()); }