From 6f4ed40496afd89778f81234b32131014dff6610 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 27 Jul 2010 18:32:10 +0000 Subject: [PATCH] - added TIHan's ArmorFactor submission. SVN r2465 (trunk) --- src/g_level.h | 4 +++- src/g_shared/a_armor.cpp | 24 ++++++++++++++++++++++++ src/g_skill.cpp | 13 ++++++++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/g_level.h b/src/g_level.h index 701437452..f316491d5 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -548,7 +548,8 @@ enum ESkillProperty SKILLP_ACSReturn, SKILLP_MonsterHealth, SKILLP_FriendlyHealth, - SKILLP_NoPain + SKILLP_NoPain, + SKILLP_ArmorFactor }; int G_SkillProperty(ESkillProperty prop); const char * G_SkillName(); @@ -583,6 +584,7 @@ struct FSkillInfo fixed_t MonsterHealth; fixed_t FriendlyHealth; bool NoPain; + fixed_t ArmorFactor; FSkillInfo() {} FSkillInfo(const FSkillInfo &other) diff --git a/src/g_shared/a_armor.cpp b/src/g_shared/a_armor.cpp index 9e43ccfb6..6dd39885d 100644 --- a/src/g_shared/a_armor.cpp +++ b/src/g_shared/a_armor.cpp @@ -5,6 +5,7 @@ #include "r_data.h" #include "a_pickups.h" #include "templates.h" +#include "g_level.h" IMPLEMENT_CLASS (AArmor) @@ -84,6 +85,18 @@ bool ABasicArmor::HandlePickup (AInventory *item) // You shouldn't be picking up BasicArmor anyway. return true; } + if (item->IsKindOf(RUNTIME_CLASS(ABasicArmorBonus)) && !(item->ItemFlags & IF_IGNORESKILL)) + { + ABasicArmorBonus *armor = static_cast(item); + + armor->SaveAmount = FixedMul(armor->SaveAmount, G_SkillProperty(SKILLP_ArmorFactor)); + } + else if (item->IsKindOf(RUNTIME_CLASS(ABasicArmorPickup)) && !(item->ItemFlags & IF_IGNORESKILL)) + { + ABasicArmorPickup *armor = static_cast(item); + + armor->SaveAmount = FixedMul(armor->SaveAmount, G_SkillProperty(SKILLP_ArmorFactor)); + } if (Inventory != NULL) { return Inventory->HandlePickup (item); @@ -202,6 +215,12 @@ AInventory *ABasicArmorPickup::CreateCopy (AActor *other) copy->SaveAmount = SaveAmount; copy->MaxAbsorb = MaxAbsorb; copy->MaxFullAbsorb = MaxFullAbsorb; + + if (!(ItemFlags & IF_IGNORESKILL)) + { // extra ammo in baby mode and nightmare mode + SaveAmount = FixedMul(SaveAmount, G_SkillProperty(SKILLP_ArmorFactor)); + } + return copy; } @@ -279,6 +298,11 @@ AInventory *ABasicArmorBonus::CreateCopy (AActor *other) copy->BonusMax = BonusMax; copy->MaxAbsorb = MaxAbsorb; copy->MaxFullAbsorb = MaxFullAbsorb; + + if (!(ItemFlags & IF_IGNORESKILL)) + { // extra ammo in baby mode and nightmare mode + SaveAmount = FixedMul(SaveAmount, G_SkillProperty(SKILLP_ArmorFactor)); + } return copy; } diff --git a/src/g_skill.cpp b/src/g_skill.cpp index 424b69a47..cac38563a 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -80,6 +80,7 @@ void FMapInfoParser::ParseSkill () skill.MonsterHealth = FRACUNIT; skill.FriendlyHealth = FRACUNIT; skill.NoPain = false; + skill.ArmorFactor = FRACUNIT; sc.MustGetString(); skill.Name = sc.String; @@ -249,6 +250,12 @@ void FMapInfoParser::ParseSkill () { skill.NoPain = true; } + else if (sc.Compare("ArmorFactor")) + { + ParseAssign(); + sc.MustGetFloat(); + skill.ArmorFactor = FLOAT2FIXED(sc.Float); + } else if (sc.Compare("DefaultSkill")) { if (DefaultSkill >= 0) @@ -357,7 +364,10 @@ int G_SkillProperty(ESkillProperty prop) return AllSkills[gameskill].FriendlyHealth; case SKILLP_NoPain: - return AllSkills[gameskill].NoPain; + return AllSkills[gameskill].NoPain; + + case SKILLP_ArmorFactor: + return AllSkills[gameskill].ArmorFactor; } } return 0; @@ -435,6 +445,7 @@ FSkillInfo &FSkillInfo::operator=(const FSkillInfo &other) MonsterHealth = other.MonsterHealth; FriendlyHealth = other.FriendlyHealth; NoPain = other.NoPain; + ArmorFactor = other.ArmorFactor; return *this; }