Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: negative bonus effects #2200

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions Intersect.Client/Interface/Game/Character/CharacterWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions Intersect.Editor/Forms/Editors/frmItem.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

175 changes: 92 additions & 83 deletions Intersect.Server.Core/Entities/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down