Skip to content

Fixed "Weakens Armor" enchantment not being applied #2616

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

Open
wants to merge 1 commit into
base: master
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
8 changes: 5 additions & 3 deletions Assets/Scripts/Game/Entities/DaggerfallEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public void SetIncreasedWeightAllowanceMultiplier(float amount)

public void SetIncreasedArmorValueModifier(int amount)
{
// Increased armor value does not stack, only effect with the highest modifier used
// Increased armor value does not stack, only effect with the strongest modifier used
// In classic effects this never goes below -5 (lower modifier -> higher armor)
if (amount < IncreasedArmorValueModifier)
{
Expand All @@ -409,10 +409,12 @@ public void SetIncreasedArmorValueModifier(int amount)

public void SetDecreasedArmorValueModifier(int amount)
{
// Decreased armor value does not stack, only effect with the lowest modifier uses
// Decreased armor value does not stack, only effect with the strongest modifier uses
// In classic effects this never goes above +5 (higher modifier -> lower armor)
if (amount < DecreasedArmorValueModifier)
if (amount > DecreasedArmorValueModifier)
{
DecreasedArmorValueModifier = amount;
}
}

public void ChangeChanceToHitModifier(int amount)
Expand Down
31 changes: 20 additions & 11 deletions Assets/Scripts/Game/UserInterface/PaperDoll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,29 @@ void RefreshArmourValues(PlayerEntity playerEntity, bool suppress = false)
if (!showArmorLabels)
return;

// "Increased" armor value modifier is negative or 0
// "Decreased" armor value modifier is positive or 0
// They are applied directly as a hit malus/bonus when an enemy attacks

// For the purpose of UI, we invert this logic
// We show bonuses as bigger numbers and maluses as small numbers
// Also, 1 AC = 5 hit modifier
// Therefore, a -5 "Increase" armor value gives +1 AC
// and a +5 "Decrease" armopr values gives -1 AC

int avMod = playerEntity.IncreasedArmorValueModifier + playerEntity.DecreasedArmorValueModifier;
Color textColor = DaggerfallUI.DaggerfallDefaultTextColor;
if (avMod > 0)
textColor = DaggerfallUI.DaggerfallUnityStatDrainedTextColor;
else if (avMod < 0)
textColor = DaggerfallUI.DaggerfallUnityStatIncreasedTextColor;

for (int bpIdx = 0; bpIdx < DaggerfallEntity.NumberBodyParts; bpIdx++)
{
int armorMod = playerEntity.DecreasedArmorValueModifier - playerEntity.IncreasedArmorValueModifier;

sbyte av = playerEntity.ArmorValues[bpIdx];
int bpAv = (100 - av) / 5 + armorMod;
armourLabels[bpIdx].Text = (!suppress) ? bpAv.ToString() : string.Empty;

if (armorMod < 0)
armourLabels[bpIdx].TextColor = DaggerfallUI.DaggerfallUnityStatDrainedTextColor;
else if (armorMod > 0)
armourLabels[bpIdx].TextColor = DaggerfallUI.DaggerfallUnityStatIncreasedTextColor;
else
armourLabels[bpIdx].TextColor = DaggerfallUI.DaggerfallDefaultTextColor;
int ac = (100 - (av + avMod)) / 5;
armourLabels[bpIdx].Text = (!suppress) ? ac.ToString() : string.Empty;
armourLabels[bpIdx].TextColor = textColor;
}
}

Expand Down