From 56e08dbeae87d80885bd8078fe4cc654a745dee2 Mon Sep 17 00:00:00 2001 From: Wanne Date: Tue, 15 Jan 2013 20:04:41 +0000 Subject: [PATCH] Fixes (by Buggler) - Fixed allow exception to Dr Q. skill trait code not fully functional - Swapped Dr Q. skill trait xml order so that when exception disabled, he will still have his night ops minor skill due to code execution order - Externalized allow_exception ID number for modding git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5791 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameSettings.cpp | 5 +++-- GameSettings.h | 3 ++- Tactical/Soldier Control.cpp | 26 ++++++++++++++------------ Tactical/Soldier Profile.cpp | 13 +++++++++++-- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/GameSettings.cpp b/GameSettings.cpp index 0554ba09..454269b1 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -1925,8 +1925,9 @@ void LoadSkillTraitsExternalSettings() gSkillTraitValues.ubMaxNumberOfTraits = iniReader.ReadInteger("Generic Traits Settings","MAX_NUMBER_OF_TRAITS", 3, 2, 30); gSkillTraitValues.ubNumberOfMajorTraitsAllowed = iniReader.ReadInteger("Generic Traits Settings","NUMBER_OF_MAJOR_TRAITS_ALLOWED", 2, 2, 20); - // Allow an exception in number of traits for Dr.Q? - gSkillTraitValues.fAllowDrQTraitsException = iniReader.ReadBoolean("Generic Traits Settings","ALLOW_EXCEPTION_FOR_DR_Q", TRUE); + // Allow an exception in number of traits for Special Merc? + gSkillTraitValues.fAllowSpecialMercTraitsException = iniReader.ReadBoolean("Generic Traits Settings","ALLOW_EXCEPTION_FOR_SPECIAL_MERC", TRUE); + gSkillTraitValues.ubSpecialMercID = iniReader.ReadInteger("Generic Traits Settings","SPECIAL_MERC_ID", 33, 0, 254); // Allow traits prerequisities for attributes? gSkillTraitValues.fAllowAttributePrereq = iniReader.ReadBoolean("Generic Traits Settings","SET_MINIMUM_ATTRIBUTES_FOR_TRAITS", TRUE); diff --git a/GameSettings.h b/GameSettings.h index e1e5d4ad..d3253a82 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -1211,7 +1211,8 @@ typedef struct UINT8 ubMaxNumberOfTraits; UINT8 ubNumberOfMajorTraitsAllowed; - BOOLEAN fAllowDrQTraitsException; + BOOLEAN fAllowSpecialMercTraitsException; + UINT8 ubSpecialMercID; BOOLEAN fAllowAttributePrereq; diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index c74af50a..d2fd4a42 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -17838,16 +17838,17 @@ BOOLEAN HAS_SKILL_TRAIT( SOLDIERTYPE * pSoldier, UINT8 uiSkillTraitNumber ) INT8 bNumMajorTraitsCounted = 0; INT8 bMaxTraits = gSkillTraitValues.ubMaxNumberOfTraits; INT8 bMaxMajorTraits = gSkillTraitValues.ubNumberOfMajorTraitsAllowed; - // special case for Dr.Q - he's allowed to have 3 major traits and one minor for total by default - if ( pSoldier->ubProfile == 33 && gSkillTraitValues.fAllowDrQTraitsException ) - { - bMaxTraits++; - bMaxMajorTraits++; - } // check old/new traits if (gGameOptions.fNewTraitSystem) { + // exception for special merc + if ( gSkillTraitValues.fAllowSpecialMercTraitsException && pSoldier->ubProfile == gSkillTraitValues.ubSpecialMercID) + { + bMaxTraits++; + bMaxMajorTraits++; + } + for ( INT8 bCnt = 0; bCnt < min(30,bMaxTraits); bCnt++ ) { if ( TwoStagedTrait( uiSkillTraitNumber ) ) @@ -17894,16 +17895,17 @@ INT8 NUM_SKILL_TRAITS( SOLDIERTYPE * pSoldier, UINT8 uiSkillTraitNumber ) INT8 bNumMajorTraitsCounted = 0; INT8 bMaxTraits = gSkillTraitValues.ubMaxNumberOfTraits; INT8 bMaxMajorTraits = gSkillTraitValues.ubNumberOfMajorTraitsAllowed; - // special case for Dr.Q - he's allowed to have 3 major traits and one minor for total by default - if ( pSoldier->ubProfile == 33 && gSkillTraitValues.fAllowDrQTraitsException ) - { - bMaxTraits++; - bMaxMajorTraits++; - } // check old/new traits if (gGameOptions.fNewTraitSystem) { + // exception for special merc + if ( gSkillTraitValues.fAllowSpecialMercTraitsException && pSoldier->ubProfile == gSkillTraitValues.ubSpecialMercID) + { + bMaxTraits++; + bMaxMajorTraits++; + } + for ( INT8 bCnt = 0; bCnt < min(30,bMaxTraits); bCnt++ ) { if ( TwoStagedTrait( uiSkillTraitNumber ) ) diff --git a/Tactical/Soldier Profile.cpp b/Tactical/Soldier Profile.cpp index 1ad0b2a0..0f8ca05e 100644 --- a/Tactical/Soldier Profile.cpp +++ b/Tactical/Soldier Profile.cpp @@ -2657,11 +2657,20 @@ INT8 ProfileHasSkillTrait( INT32 ubProfileID, INT8 bSkillTrait ) { INT8 bNumTraits = 0; INT8 bNumMajorTraitsCounted = 0; + INT8 bMaxTraits = gSkillTraitValues.ubMaxNumberOfTraits; + INT8 bMaxMajorTraits = gSkillTraitValues.ubNumberOfMajorTraitsAllowed; // check old/new traits if (gGameOptions.fNewTraitSystem) { - for ( INT8 bCnt = 0; bCnt < gSkillTraitValues.ubMaxNumberOfTraits; bCnt++ ) + // exception for special merc + if ( gSkillTraitValues.fAllowSpecialMercTraitsException && ubProfileID == gSkillTraitValues.ubSpecialMercID) + { + bMaxTraits++; + bMaxMajorTraits++; + } + + for ( INT8 bCnt = 0; bCnt < bMaxTraits; bCnt++ ) { if ( TwoStagedTrait(bSkillTrait) ) { @@ -2675,7 +2684,7 @@ INT8 ProfileHasSkillTrait( INT32 ubProfileID, INT8 bSkillTrait ) bNumMajorTraitsCounted++; } // if we exceeded the allowed number of major traits, ignore the rest of them - if ( bNumMajorTraitsCounted >= gSkillTraitValues.ubNumberOfMajorTraitsAllowed ) + if ( bNumMajorTraitsCounted >= bMaxMajorTraits ) { break; }