Merge pull request #900 from Blue-Shadow/armorfactor_fix

- fixed buggy ArmorFactor behavior when set to a value other than 1.0
This commit is contained in:
Christoph Oelckers 2019-08-03 21:42:11 +02:00 committed by GitHub
commit 3c0ff178fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -132,19 +132,6 @@ class BasicArmor : Armor
// You shouldn't be picking up BasicArmor anyway. // You shouldn't be picking up BasicArmor anyway.
return true; return true;
} }
if (!item.bIgnoreSkill)
{
if (item is "BasicArmorBonus")
{
let armor = BasicArmorBonus(item);
armor.SaveAmount = int(armor.SaveAmount * G_SkillPropertyFloat(SKILLP_ArmorFactor));
}
else if (item is "BasicArmorPickup")
{
let armor = BasicArmorPickup(item);
armor.SaveAmount = int(armor.SaveAmount * G_SkillPropertyFloat(SKILLP_ArmorFactor));
}
}
return false; return false;
} }
@ -263,12 +250,6 @@ class BasicArmorBonus : Armor
override Inventory CreateCopy (Actor other) override Inventory CreateCopy (Actor other)
{ {
let copy = BasicArmorBonus(Super.CreateCopy (other)); let copy = BasicArmorBonus(Super.CreateCopy (other));
if (!bIgnoreSkill)
{
SaveAmount = int(SaveAmount * G_SkillPropertyFloat(SKILLP_ArmorFactor));
}
copy.SavePercent = SavePercent; copy.SavePercent = SavePercent;
copy.SaveAmount = SaveAmount; copy.SaveAmount = SaveAmount;
copy.MaxSaveAmount = MaxSaveAmount; copy.MaxSaveAmount = MaxSaveAmount;
@ -309,7 +290,7 @@ class BasicArmorBonus : Armor
result = true; result = true;
} }
int saveAmount = min(SaveAmount, MaxSaveAmount); int saveAmount = min(GetSaveAmount(), MaxSaveAmount);
if (saveAmount <= 0) if (saveAmount <= 0)
{ // If it can't give you anything, it's as good as used. { // If it can't give you anything, it's as good as used.
@ -344,6 +325,11 @@ class BasicArmorBonus : Armor
{ {
SaveAmount *= amount; SaveAmount *= amount;
} }
int GetSaveAmount ()
{
return !bIgnoreSkill ? int(SaveAmount * G_SkillPropertyFloat(SKILLP_ArmorFactor)) : SaveAmount;
}
} }
//=========================================================================== //===========================================================================
@ -383,12 +369,6 @@ class BasicArmorPickup : Armor
override Inventory CreateCopy (Actor other) override Inventory CreateCopy (Actor other)
{ {
let copy = BasicArmorPickup(Super.CreateCopy (other)); let copy = BasicArmorPickup(Super.CreateCopy (other));
if (!bIgnoreSkill)
{
SaveAmount = int(SaveAmount * G_SkillPropertyFloat(SKILLP_ArmorFactor));
}
copy.SavePercent = SavePercent; copy.SavePercent = SavePercent;
copy.SaveAmount = SaveAmount; copy.SaveAmount = SaveAmount;
copy.MaxAbsorb = MaxAbsorb; copy.MaxAbsorb = MaxAbsorb;
@ -410,6 +390,7 @@ class BasicArmorPickup : Armor
override bool Use (bool pickup) override bool Use (bool pickup)
{ {
int SaveAmount = GetSaveAmount();
let armor = BasicArmor(Owner.FindInventory("BasicArmor")); let armor = BasicArmor(Owner.FindInventory("BasicArmor"));
// This should really never happen but let's be prepared for a broken inventory. // This should really never happen but let's be prepared for a broken inventory.
@ -450,6 +431,10 @@ class BasicArmorPickup : Armor
SaveAmount *= amount; SaveAmount *= amount;
} }
int GetSaveAmount ()
{
return !bIgnoreSkill ? int(SaveAmount * G_SkillPropertyFloat(SKILLP_ArmorFactor)) : SaveAmount;
}
} }
//=========================================================================== //===========================================================================