diff --git a/Intersect.Client/Interface/Game/Character/CharacterWindow.cs b/Intersect.Client/Interface/Game/Character/CharacterWindow.cs index 6b11001a3f..c8868d59d2 100644 --- a/Intersect.Client/Interface/Game/Character/CharacterWindow.cs +++ b/Intersect.Client/Interface/Game/Character/CharacterWindow.cs @@ -449,14 +449,10 @@ public void UpdateExtraBuffs(Guid itemId) } //Getting extra buffs - if (item.Effects.Find(effect => effect.Type != ItemEffect.None && effect.Percentage > 0) != default) + if (item.Effects.Find(effect => effect.Type != ItemEffect.None) != default) { foreach(var effect in item.Effects) { - if (effect.Percentage <= 0) - { - continue; - } switch (effect.Type) { @@ -467,8 +463,15 @@ public void UpdateExtraBuffs(Guid itemId) break; case ItemEffect.Lifesteal: LifeStealAmount += effect.Percentage; - mLifeSteal?.SetText(Strings.Character.Lifesteal.ToString(LifeStealAmount)); - + // Checks if LifeStealAmount is less than 0, if so, sets the text to "0" + if (LifeStealAmount < 0) + { + mLifeSteal?.SetText(Strings.Character.Lifesteal.ToString(0)); + } + else + { + mLifeSteal?.SetText(Strings.Character.Lifesteal.ToString(LifeStealAmount)); + } break; case ItemEffect.Tenacity: TenacityAmount += effect.Percentage; @@ -487,6 +490,16 @@ public void UpdateExtraBuffs(Guid itemId) break; case ItemEffect.Manasteal: ManaStealAmount += effect.Percentage; + // Checks if ManaStealAmount is less than 0, if so, sets the text to "0" + if (ManaStealAmount < 0) + { + mManaSteal?.SetText(Strings.Character.Manasteal.ToString(0)); + } + else + { + mManaSteal?.SetText(Strings.Character.Manasteal.ToString(ManaStealAmount)); + } + break; mManaSteal?.SetText(Strings.Character.Manasteal.ToString(ManaStealAmount)); break; diff --git a/Intersect.Editor/Forms/Editors/frmItem.Designer.cs b/Intersect.Editor/Forms/Editors/frmItem.Designer.cs index b1932ccb61..68666af5a7 100644 --- a/Intersect.Editor/Forms/Editors/frmItem.Designer.cs +++ b/Intersect.Editor/Forms/Editors/frmItem.Designer.cs @@ -1697,6 +1697,8 @@ private void InitializeComponent() nudEffectPercent.ForeColor = System.Drawing.Color.Gainsboro; nudEffectPercent.Location = new System.Drawing.Point(15, 190); nudEffectPercent.Margin = new Padding(4, 3, 4, 3); + nudEffectPercent.Maximum = new decimal(new int[] { 100, 0, 0, 0 }); + nudEffectPercent.Minimum = new decimal(new int[] { -100, 0, 0, int.MinValue }); nudEffectPercent.Name = "nudEffectPercent"; nudEffectPercent.Size = new Size(282, 23); nudEffectPercent.TabIndex = 55; diff --git a/Intersect.Server.Core/Entities/Entity.cs b/Intersect.Server.Core/Entities/Entity.cs index d74b6cc14e..a9536bd24e 100644 --- a/Intersect.Server.Core/Entities/Entity.cs +++ b/Intersect.Server.Core/Entities/Entity.cs @@ -2081,120 +2081,129 @@ public void Attack( var thisPlayer = this as Player; //Check for lifesteal/manasteal - if (this is Player && !(enemy is Resource)) - { - var lifestealRate = thisPlayer.GetEquipmentBonusEffect(ItemEffect.Lifesteal) / 100f; - var idealHealthRecovered = lifestealRate * baseDamage; - var actualHealthRecovered = Math.Min(enemyVitals[(int)Vital.Health], idealHealthRecovered); - - if (actualHealthRecovered > 0) + if (baseDamage > 0 && this != enemy) + if (this is Player && !(enemy is Resource)) { - // Don't send any +0 msg's. - AddVital(Vital.Health, (int)actualHealthRecovered); - PacketSender.SendActionMsg( - this, - Strings.Combat.addsymbol + (int)actualHealthRecovered, - CustomColors.Combat.Heal - ); - } + var lifestealRate = thisPlayer.GetEquipmentBonusEffect(ItemEffect.Lifesteal) / 100f; + if (lifestealRate < 0) + { + lifestealRate = 0; // Jeśli lifestealRate jest ujemny, ustaw na zero + } + var idealHealthRecovered = lifestealRate * baseDamage; + var actualHealthRecovered = Math.Min(enemyVitals[(int)Vital.Health], idealHealthRecovered); - var manastealRate = (thisPlayer.GetEquipmentBonusEffect(ItemEffect.Manasteal) / 100f); - var idealManaRecovered = manastealRate * baseDamage; - var actualManaRecovered = Math.Min(enemyVitals[(int)Vital.Mana], idealManaRecovered); + if (actualHealthRecovered > 0) + { + // Don't send any +0 msg's. + AddVital(Vital.Health, (int)actualHealthRecovered); + PacketSender.SendActionMsg( + this, + Strings.Combat.addsymbol + (int)actualHealthRecovered, + CustomColors.Combat.Heal + ); + } - if (actualManaRecovered > 0) - { - // Don't send any +0 msg's. - AddVital(Vital.Mana, (int)actualManaRecovered); - enemy.SubVital(Vital.Mana, (int)actualManaRecovered); - PacketSender.SendActionMsg( - this, - Strings.Combat.addsymbol + (int)actualManaRecovered, - CustomColors.Combat.AddMana - ); - } + var manastealRate = (thisPlayer.GetEquipmentBonusEffect(ItemEffect.Manasteal) / 100f); + if (manastealRate < 0) + { + manastealRate = 0; // Jeśli manastealRate jest ujemny, ustaw na zero + } + var idealManaRecovered = manastealRate * baseDamage; + var actualManaRecovered = Math.Min(enemyVitals[(int)Vital.Mana], idealManaRecovered); - var remainingManaRecovery = idealManaRecovered - actualManaRecovered; - if (remainingManaRecovery > 0) - { - // If the mana recovered is less than it should be, deal the remainder as bonus damage - enemy.SubVital(Vital.Health, (int)remainingManaRecovery); - PacketSender.SendActionMsg( - enemy, - Strings.Combat.removesymbol + remainingManaRecovery, - CustomColors.Combat.TrueDamage - ); + if (actualManaRecovered > 0) + { + // Don't send any +0 msg's. + AddVital(Vital.Mana, (int)actualManaRecovered); + enemy.SubVital(Vital.Mana, (int)actualManaRecovered); + PacketSender.SendActionMsg( + this, + Strings.Combat.addsymbol + (int)actualManaRecovered, + CustomColors.Combat.AddMana + ); + } + + var remainingManaRecovery = idealManaRecovered - actualManaRecovered; + if (remainingManaRecovery > 0) + { + // If the mana recovered is less than it should be, deal the remainder as bonus damage + enemy.SubVital(Vital.Health, (int)remainingManaRecovery); + PacketSender.SendActionMsg( + enemy, + Strings.Combat.removesymbol + remainingManaRecovery, + CustomColors.Combat.TrueDamage + ); + } } - } //Dead entity check if (enemy.GetVital(Vital.Health) <= 0) - { - if (enemy is Npc || enemy is Resource) { - lock (enemy.EntityLock) + if (enemy is Npc || enemy is Resource) { - enemy.Die(true, this); + lock (enemy.EntityLock) + { + enemy.Die(true, this); + } } - } - else - { - //PVP Kill common events - if (!enemy.Dead && enemy is Player enemyPlayer && this is Player) + else { - thisPlayer.StartCommonEventsWithTrigger(CommonEventTrigger.PVPKill, "", enemy.Name); - enemyPlayer.StartCommonEventsWithTrigger(CommonEventTrigger.PVPDeath, "", this.Name); + //PVP Kill common events + if (!enemy.Dead && enemy is Player enemyPlayer && this is Player) + { + thisPlayer.StartCommonEventsWithTrigger(CommonEventTrigger.PVPKill, "", enemy.Name); + enemyPlayer.StartCommonEventsWithTrigger(CommonEventTrigger.PVPDeath, "", this.Name); + } + + lock (enemy.EntityLock) + { + enemy.Die(true, this); + } } - lock (enemy.EntityLock) + if (deadAnimations != null) { - enemy.Die(true, this); + foreach (var anim in deadAnimations) + { + PacketSender.SendAnimationToProximity( + anim.Key, -1, Id, enemy.MapId, enemy.X, enemy.Y, anim.Value, MapInstanceId + ); + } } } - - if (deadAnimations != null) + else { - foreach (var anim in deadAnimations) + //Hit him, make him mad and send the vital update. + if (aliveAnimations?.Count > 0) { - PacketSender.SendAnimationToProximity( - anim.Key, -1, Id, enemy.MapId, enemy.X, enemy.Y, anim.Value, MapInstanceId - ); + Animate(enemy, aliveAnimations); } + + //Check for any onhit damage bonus effects! + CheckForOnhitAttack(enemy, isAutoAttack); } - } - else - { - //Hit him, make him mad and send the vital update. - if (aliveAnimations?.Count > 0) + + // Add a timer before able to make the next move. + if (this is Npc thisNpc) { - Animate(enemy, aliveAnimations); + thisNpc.MoveTimer = Timing.Global.Milliseconds + (long)GetMovementTime(); } - - //Check for any onhit damage bonus effects! - CheckForOnhitAttack(enemy, isAutoAttack); - } - - // Add a timer before able to make the next move. - if (this is Npc thisNpc) - { - thisNpc.MoveTimer = Timing.Global.Milliseconds + (long)GetMovementTime(); } - } - void CheckForOnhitAttack(Entity enemy, bool isAutoAttack) - { - if (isAutoAttack) //Ignore spell damage. + void CheckForOnhitAttack(Entity enemy, bool isAutoAttack) { - foreach (var status in CachedStatuses) + if (isAutoAttack) //Ignore spell damage. { - if (status.Type == SpellEffect.OnHit) + foreach (var status in CachedStatuses) { - TryAttack(enemy, status.Spell, true); - status.RemoveStatus(); + if (status.Type == SpellEffect.OnHit) + { + TryAttack(enemy, status.Spell, true); + status.RemoveStatus(); + } } } } - } public virtual void KilledEntity(Entity entity) {