From 7ba509cd40d1a522aba60f9104f144fb06232e21 Mon Sep 17 00:00:00 2001 From: Wanne Date: Tue, 27 Dec 2011 15:39:52 +0000 Subject: [PATCH] New "mini" Feature: Added possibility to set optional Tag in MercStartingGear.xml to define absolute prices for gearkits (by Tais) - I put both (startup and gearkit selection in BR's) the initializations for gearkit prices into if's that will check if the absolute price is higher than -1 and lower or equal to 32000 (INT16) - I also added the reading of the tag in xml_mercstartinggear.cpp, to be able to support zero priced gearkits in absolute prices I set the absolute price of a gearkit to -1 on opening tag of a gearkit, if there's an mAbsolutePrice tag set in the gearkit it will override the value, if not nothing happens and all will behave normal - so nothing will change in 1.13 as it is, it will just give modders the ability to set absolute prices with a new tag TODO: Maybe we should also add this optional tag to the XML Editor in the future. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4868 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Laptop/AimMembers.cpp | 49 +++++++++++++++----------- Tactical/Soldier Control.cpp | 1 + Tactical/Soldier Profile.cpp | 57 +++++++++++++++++-------------- Tactical/XML_MercStartingGear.cpp | 12 +++++-- Tactical/soldier profile type.h | 1 + 5 files changed, 73 insertions(+), 47 deletions(-) diff --git a/Laptop/AimMembers.cpp b/Laptop/AimMembers.cpp index 0b76d8ce..dbf17f1c 100644 --- a/Laptop/AimMembers.cpp +++ b/Laptop/AimMembers.cpp @@ -5565,30 +5565,39 @@ void WeaponKitSelectionUpdate(UINT8 selectedInventory = 0) } } } - gMercProfiles[ gbCurrentSoldier ].usOptionalGearCost = 0; - UINT16 tempGearCost = 0; - for ( uiLoop = 0; uiLoop< gMercProfiles[ gbCurrentSoldier ].inv.size(); uiLoop++ ) - { - if ( gMercProfiles[ gbCurrentSoldier ].inv[ uiLoop ] != NOTHING ) - { - //get the item - usItem = gMercProfiles[ gbCurrentSoldier ].inv[ uiLoop ]; - //add the cost - tempGearCost += Item[ usItem ].usPrice; - } - } - //tais: added optional price modifier for gearkits, reads the xml tag mPriceMod from MercStartingGear.xml - if(gMercProfileGear[gbCurrentSoldier][selectedInventory].PriceModifier != 0 && - gMercProfileGear[gbCurrentSoldier][selectedInventory].PriceModifier <= 200 && - gMercProfileGear[gbCurrentSoldier][selectedInventory].PriceModifier >= -100) + gMercProfiles[ gbCurrentSoldier ].usOptionalGearCost = 0; + //tais: new tag in gearkit that sets an absolute price for gearkit that will override item value and price modifier if it's a sensible value between 0 and 32000 + if(gMercProfileGear[gbCurrentSoldier][selectedInventory].AbsolutePrice >= 0 && gMercProfileGear[gbCurrentSoldier][selectedInventory].AbsolutePrice <= 32000) { - FLOAT mod; - mod = (FLOAT) (gMercProfileGear[gbCurrentSoldier][selectedInventory].PriceModifier + 100) / 100; - gMercProfiles[ gbCurrentSoldier ].usOptionalGearCost = (UINT16)(tempGearCost * mod); + gMercProfiles[ gbCurrentSoldier ].usOptionalGearCost = gMercProfileGear[gbCurrentSoldier][selectedInventory].AbsolutePrice; } else { - gMercProfiles[ gbCurrentSoldier ].usOptionalGearCost = tempGearCost; + UINT16 tempGearCost = 0; + for ( uiLoop = 0; uiLoop< gMercProfiles[ gbCurrentSoldier ].inv.size(); uiLoop++ ) + { + if ( gMercProfiles[ gbCurrentSoldier ].inv[ uiLoop ] != NOTHING ) + { + //get the item + usItem = gMercProfiles[ gbCurrentSoldier ].inv[ uiLoop ]; + + //add the cost + tempGearCost += Item[ usItem ].usPrice; + } + } + //tais: added optional price modifier for gearkits, reads the xml tag mPriceMod from MercStartingGear.xml + if(gMercProfileGear[gbCurrentSoldier][selectedInventory].PriceModifier != 0 && + gMercProfileGear[gbCurrentSoldier][selectedInventory].PriceModifier <= 200 && + gMercProfileGear[gbCurrentSoldier][selectedInventory].PriceModifier >= -100) + { + FLOAT mod; + mod = (FLOAT) (gMercProfileGear[gbCurrentSoldier][selectedInventory].PriceModifier + 100) / 100; + gMercProfiles[ gbCurrentSoldier ].usOptionalGearCost = (UINT16)(tempGearCost * mod); + } + else + { + gMercProfiles[ gbCurrentSoldier ].usOptionalGearCost = tempGearCost; + } } } diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 844ea8ed..723d7bde 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -256,6 +256,7 @@ MERCPROFILEGEAR& MERCPROFILEGEAR::operator=(const MERCPROFILEGEAR& src) { invCnt = src.invCnt; lbeCnt = src.lbeCnt; PriceModifier = src.PriceModifier; + AbsolutePrice = src.AbsolutePrice; } return *this; } diff --git a/Tactical/Soldier Profile.cpp b/Tactical/Soldier Profile.cpp index bcf1e1fe..b115c611 100644 --- a/Tactical/Soldier Profile.cpp +++ b/Tactical/Soldier Profile.cpp @@ -710,35 +710,42 @@ BOOLEAN LoadMercProfiles(void) OverwriteMercProfileWithXMLData( uiLoop ); OverwriteMercOpinionsWithXMLData( uiLoop ); } - - - //tais: moved initial price calculation down to this spot because PROFEX overwrites my gearkit prices - //with old binary file optional gear prices which got ported into MercProfiles.xml - gMercProfiles[ uiLoop ].usOptionalGearCost = 0; - UINT16 tempGearCost = 0; - for ( uiLoop2 = 0; uiLoop2< gMercProfiles[ uiLoop ].inv.size(); uiLoop2++ ) + + //tais: new tag in gearkit that sets an absolute price for gearkit that will override item value and price modifier if it's a sensible value between 0 and 32000 + if(gMercProfileGear[uiLoop][0].AbsolutePrice >= 0 && gMercProfileGear[uiLoop][0].AbsolutePrice <= 32000) { - if ( gMercProfiles[ uiLoop ].inv[ uiLoop2 ] != NOTHING ) - { - //get the item - usItem = gMercProfiles[ uiLoop ].inv[ uiLoop2 ]; - - //add the cost - tempGearCost += Item[ usItem ].usPrice; - } - } - //tais: added optional price modifier for gearkits, reads the xml tag mPriceMod from MercStartingGear.xml - if(gMercProfileGear[uiLoop][0].PriceModifier != 0 && - gMercProfileGear[uiLoop][0].PriceModifier <= 200 && - gMercProfileGear[uiLoop][0].PriceModifier >= -100) - { - FLOAT mod; - mod = (FLOAT) (gMercProfileGear[uiLoop][0].PriceModifier + 100) / 100.0f; - gMercProfiles[ uiLoop ].usOptionalGearCost = (UINT16)(tempGearCost * mod); + gMercProfiles[ uiLoop ].usOptionalGearCost = gMercProfileGear[uiLoop][0].AbsolutePrice; } else { - gMercProfiles[ uiLoop ].usOptionalGearCost = tempGearCost; + //tais: moved initial price calculation down to this spot because PROFEX overwrites my gearkit prices + //with old binary file optional gear prices which got ported into MercProfiles.xml + gMercProfiles[ uiLoop ].usOptionalGearCost = 0; + UINT16 tempGearCost = 0; + for ( uiLoop2 = 0; uiLoop2< gMercProfiles[ uiLoop ].inv.size(); uiLoop2++ ) + { + if ( gMercProfiles[ uiLoop ].inv[ uiLoop2 ] != NOTHING ) + { + //get the item + usItem = gMercProfiles[ uiLoop ].inv[ uiLoop2 ]; + + //add the cost + tempGearCost += Item[ usItem ].usPrice; + } + } + //tais: added optional price modifier for gearkits, reads the xml tag mPriceMod from MercStartingGear.xml + if(gMercProfileGear[uiLoop][0].PriceModifier != 0 && + gMercProfileGear[uiLoop][0].PriceModifier <= 200 && + gMercProfileGear[uiLoop][0].PriceModifier >= -100) + { + FLOAT mod; + mod = (FLOAT) (gMercProfileGear[uiLoop][0].PriceModifier + 100) / 100.0f; + gMercProfiles[ uiLoop ].usOptionalGearCost = (UINT16)(tempGearCost * mod); + } + else + { + gMercProfiles[ uiLoop ].usOptionalGearCost = tempGearCost; + } } // ----- WANNE.PROFILE: New Profile Loading - BEGIN diff --git a/Tactical/XML_MercStartingGear.cpp b/Tactical/XML_MercStartingGear.cpp index 06d8eb8e..c412de1f 100644 --- a/Tactical/XML_MercStartingGear.cpp +++ b/Tactical/XML_MercStartingGear.cpp @@ -66,11 +66,13 @@ MercStartingGearStartElementHandle(void *userData, const XML_Char *name, const X else if(strcmp(name, "GEARKIT") == 0 && pData->curElement == ELEMENT) { pData->curElement = ELEMENT_SUBLIST; - pData->maxReadDepth++; + //tais: absolute price needs to be set to -1 at start of every gearkit, if there's no tag for it the value will stay -1 and will be ignored in the code + pData->curMercStartingGear.AbsolutePrice = -1; } else if(pData->curElement == ELEMENT_SUBLIST && - (strcmp(name, "mPriceMod") == 0 || + (strcmp(name, "mAbsolutePrice") == 0 || + strcmp(name, "mPriceMod") == 0 || strcmp(name, "mHelmet") == 0 || strcmp(name, "mHelmetStatus") == 0 || strcmp(name, "mHelmetDrop") == 0 || @@ -206,6 +208,7 @@ MercStartingGearEndElementHandle(void *userData, const XML_Char *name) pData->curArray[pData->curIndex][pData->curGears] = pData->curMercStartingGear; //write the armour into the table //CHRISL: after writing the gearkit, we need to clear gear data so it won't inadvertantly be reused pData->curMercStartingGear.PriceModifier = 0; + pData->curMercStartingGear.AbsolutePrice = -1; for(unsigned int i = 0; i < pData->curMercStartingGear.inv.size(); i++) { pData->curMercStartingGear.inv[i] = 0; @@ -229,6 +232,11 @@ MercStartingGearEndElementHandle(void *userData, const XML_Char *name) pData->curElement = ELEMENT_SUBLIST; pData->curMercStartingGear.PriceModifier = (int) atol(pData->szCharData); } + else if(strcmp(name, "mAbsolutePrice") == 0) + { + pData->curElement = ELEMENT_SUBLIST; + pData->curMercStartingGear.AbsolutePrice = (int) atol(pData->szCharData); + } else if(strcmp(name, "mHelmet") == 0) { pData->curElement = ELEMENT_SUBLIST; diff --git a/Tactical/soldier profile type.h b/Tactical/soldier profile type.h index 10f935bd..a3042073 100644 --- a/Tactical/soldier profile type.h +++ b/Tactical/soldier profile type.h @@ -330,6 +330,7 @@ public: public: UINT16 mIndex; INT16 PriceModifier; + INT16 AbsolutePrice; CHAR8 mName[80]; char endOfPOD; // marker for end of POD (plain old data) std::vector inv;