From 60d9fae2b06f3659bf99beeef46af85eb86c8886 Mon Sep 17 00:00:00 2001 From: Wanne Date: Thu, 5 Dec 2013 08:05:27 +0000 Subject: [PATCH] Added new merge type "USE_ITEM_NEW" -> MergeType: 13 (by Sevenfm) 1.) USE_ITEM_NEW - It creates new items with firstResultingItemIndex and secondResultingItemIndex (if defined) and deducts 1 point from firstItemIndex's status (for each new item). - When firstItemIndex's status reaches 0, the item is destroyed. - With this type of merge, you can use knife on tripwire roll, for example, to get 2 new tripwire items. So you can think of tripwire roll as container for 100 tripwires. 299 1640 1524 1524 13 20 2) USE_ITEM merge creates secondResultingItemIndex item if defined. - With this secondResultingItemIndex defined, you can use knife on T-Shirt to get 2 rags. 299 195 1022 1022 6 20 git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6681 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Item Types.h | 1 + Tactical/Items.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/Tactical/Item Types.h b/Tactical/Item Types.h index 1276a3b5..0ae8a766 100644 --- a/Tactical/Item Types.h +++ b/Tactical/Item Types.h @@ -1780,6 +1780,7 @@ typedef enum MECHANICAL_MERGE_EASY, MECHANICAL_MERGE_HARD, TRIPWIRE_ROLL, + USE_ITEM_NEW, } MergeType; extern UINT16 Merge[MAXITEMS+1][6]; diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 2e9aa470..05975ae0 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -5020,6 +5020,35 @@ BOOLEAN OBJECTTYPE::AttachObjectNAS( SOLDIERTYPE * pSoldier, OBJECTTYPE * pAttac switch( ubType ) { + case USE_ITEM_NEW: + if( (*this)[subObject]->data.objectStatus >0 && usResult != NOTHING) + { + CreateItem( usResult, 100, &gTempObject ); + if ( !AutoPlaceObject( pSoldier, &gTempObject, FALSE ) ) + AddItemToPool( pSoldier->sGridNo, &gTempObject, 1, 0, 0, -1 ); + (*this)[subObject]->data.objectStatus--; + } + if( (*this)[subObject]->data.objectStatus >0 && usResult2 != NOTHING ) + { + CreateItem( usResult2, 100, &gTempObject ); + if ( !AutoPlaceObject( pSoldier, &gTempObject, FALSE ) ) + AddItemToPool( pSoldier->sGridNo, &gTempObject, 1, 0, 0, -1 ); + (*this)[subObject]->data.objectStatus--; + } + if( (*this)[subObject]->data.objectStatus == 0 ) + { + this->RemoveObjectsFromStack(1); + if ( pSoldier && pSoldier->bTeam == gbPlayerNum ) + { + pSoldier->DoMercBattleSound( BATTLE_SOUND_CURSE1 ); + } + } else + { + if (pSoldier && pSoldier->bTeam == gbPlayerNum) + pSoldier->DoMercBattleSound( BATTLE_SOUND_COOL1 ); + } + ApplyEquipmentBonuses(pSoldier); + return TRUE; case USE_ITEM: case USE_ITEM_HARD: // the merge will combine the two items @@ -5062,6 +5091,14 @@ BOOLEAN OBJECTTYPE::AttachObjectNAS( SOLDIERTYPE * pSoldier, OBJECTTYPE * pAttac // HEADROCK HAM 5: Added argument for statusindex. ReInitMergedItem(pSoldier, this, usOldItem, 0); + // sevenfm: add usResult2 item if defined + if( usResult2 != NOTHING ) + { + CreateItem( usResult2, 100, &gTempObject ); + if ( !AutoPlaceObject( pSoldier, &gTempObject, FALSE ) ) + AddItemToPool( pSoldier->sGridNo, &gTempObject, 1, 0, 0, -1 ); + } + //AutoPlaceObject( pAttachment ); //ADB ubWeight has been removed, see comments in OBJECTTYPE //this->ubWeight = CalculateObjectWeight( this );