diff --git a/GameVersion.cpp b/GameVersion.cpp
index d7cde497..c4294d2c 100644
--- a/GameVersion.cpp
+++ b/GameVersion.cpp
@@ -23,7 +23,7 @@ INT16 zVersionLabel[256] = { L"Beta v. 0.98" };
#else
//RELEASE BUILD VERSION
- INT16 zVersionLabel[256] = { L"Release v1.13.473" };
+ INT16 zVersionLabel[256] = { L"Release v1.13.476" };
#endif
diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp
index 4443d523..b6794f2e 100644
--- a/Tactical/Interface Items.cpp
+++ b/Tactical/Interface Items.cpp
@@ -2958,7 +2958,7 @@ void ItemDescAttachmentsCallback( MOUSE_REGION * pRegion, INT32 iReason )
if ( gpItemPointer != NULL )
{
// nb pointer could be NULL because of inventory manipulation in mapscreen from sector inv
- if ( !gpItemPointerSoldier || EnoughPoints( gpItemPointerSoldier, AP_RELOAD_GUN, 0, TRUE ) )
+ if ( !gpItemPointerSoldier || EnoughPoints( gpItemPointerSoldier, AttachmentAPCost( gpItemPointer->usItem, gpItemDescObject->usItem ), 0, TRUE ) )
{
// if ( (Item[ gpItemPointer->usItem ].fFlags & ITEM_INSEPARABLE) && ValidAttachment( gpItemPointer->usItem, gpItemDescObject->usItem ) )
if ( (Item[ gpItemPointer->usItem ].inseparable ) && ValidAttachment( gpItemPointer->usItem, gpItemDescObject->usItem ) )
@@ -2973,7 +2973,7 @@ void ItemDescAttachmentsCallback( MOUSE_REGION * pRegion, INT32 iReason )
else
{
// ATE: Make sure we have enough AP's to drop it if we pick it up!
- if ( EnoughPoints( gpItemDescSoldier, ( AP_RELOAD_GUN + AP_PICKUP_ITEM ), 0, TRUE ) )
+ if ( EnoughPoints( gpItemDescSoldier, ( AttachmentAPCost( gpItemPointer->usItem, gpItemDescObject->usItem ) + AP_PICKUP_ITEM ), 0, TRUE ) )
{
// Get attachment if there is one
// The follwing function will handle if no attachment is here
@@ -4099,6 +4099,7 @@ void DeleteItemDescriptionBox( )
{
INT32 cnt, cnt2;
BOOLEAN fFound, fAllFound;
+ UINT8 ubAPCost;
if( gfInItemDescBox == FALSE )
{
@@ -4135,6 +4136,7 @@ void DeleteItemDescriptionBox( )
if (!fFound)
{
// charge APs
+ ubAPCost = AttachmentAPCost(gusOriginalAttachItem[ cnt ],gpItemDescObject->usItem);
fAllFound = FALSE;
break;
}
@@ -4159,6 +4161,7 @@ void DeleteItemDescriptionBox( )
if (!fFound)
{
// charge APs
+ ubAPCost = AttachmentAPCost(gpItemDescObject->usAttachItem[ cnt ],gpItemDescObject->usItem);
fAllFound = FALSE;
break;
}
@@ -4168,7 +4171,7 @@ void DeleteItemDescriptionBox( )
if (!fAllFound)
{
- DeductPoints( gpAttachSoldier, AP_RELOAD_GUN, 0 );
+ DeductPoints( gpAttachSoldier, ubAPCost, 0 );
}
}
}
diff --git a/Tactical/Item Types.h b/Tactical/Item Types.h
index dcc2bc05..4b9fa903 100644
--- a/Tactical/Item Types.h
+++ b/Tactical/Item Types.h
@@ -814,7 +814,7 @@ typedef enum
#define MAXATTACHMENTS 30000
extern INVTYPE Item[MAXITEMS];
-extern UINT16 Attachment[MAXATTACHMENTS][2];
+extern UINT16 Attachment[MAXATTACHMENTS][3];
typedef struct
{
diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp
index caccef8d..b06d219c 100644
--- a/Tactical/Items.cpp
+++ b/Tactical/Items.cpp
@@ -516,7 +516,7 @@ AttachmentInfoStruct AttachmentInfo[MAXITEMS+1];// =
// { 0, 0 }
//};
-UINT16 Attachment[MAXATTACHMENTS][2];// =
+UINT16 Attachment[MAXATTACHMENTS][3];// =
//{
// {SILENCER, GLOCK_17},
// {SILENCER, GLOCK_18},
@@ -1773,9 +1773,10 @@ INT8 GetAttachmentInfoIndex( UINT16 usItem )
}
//Determine if it is possible to add this attachment to the item.
-BOOLEAN ValidAttachment( UINT16 usAttachment, UINT16 usItem )
+BOOLEAN internalValidAttachment( UINT16 usAttachment, UINT16 usItem, UINT8 * pubAPCost )
{
INT32 iLoop = 0;
+ *pubAPCost = (UINT8)AP_RELOAD_GUN; //default value
// look for the section of the array pertaining to this attachment...
while( 1 )
@@ -1796,6 +1797,7 @@ BOOLEAN ValidAttachment( UINT16 usAttachment, UINT16 usItem )
{
if (Attachment[iLoop][1] == usItem)
{
+ *pubAPCost = (UINT8)Attachment[iLoop][2]; //Madd: get ap cost of attaching items :)
break;
}
iLoop++;
@@ -1808,6 +1810,22 @@ BOOLEAN ValidAttachment( UINT16 usAttachment, UINT16 usItem )
return( TRUE );
}
+//Determine if it is possible to add this attachment to the item.
+BOOLEAN ValidAttachment( UINT16 usAttachment, UINT16 usItem )
+{
+ UINT8 ubAPCost;
+
+ return internalValidAttachment( usAttachment, usItem, &ubAPCost);
+}
+UINT8 AttachmentAPCost( UINT16 usAttachment, UINT16 usItem )
+{
+ UINT8 ubAPCost;
+
+ internalValidAttachment( usAttachment, usItem, &ubAPCost);
+
+ return ubAPCost;
+}
+
//Determine if this item can receive this attachment. This is different, in that it may
//be possible to have this attachment on this item, but may already have an attachment on
//it which doesn't work simultaneously with the new attachment (like a silencer and duckbill).
diff --git a/Tactical/Items.h b/Tactical/Items.h
index c6c4f216..799d7cb8 100644
--- a/Tactical/Items.h
+++ b/Tactical/Items.h
@@ -130,6 +130,7 @@ BOOLEAN TwoHandedItem( UINT16 usItem );
//Existing functions without header def's, added them here, just incase I'll need to call
//them from the editor.
BOOLEAN ValidAttachment( UINT16 usAttachment, UINT16 usItem );
+UINT8 AttachmentAPCost( UINT16 usAttachment, UINT16 usItem );
BOOLEAN ValidLaunchable( UINT16 usLaunchable, UINT16 usItem );
UINT16 GetLauncherFromLaunchable( UINT16 usLaunchable );
diff --git a/Tactical/XML_Attachments.cpp b/Tactical/XML_Attachments.cpp
index b052aa0b..8db8b913 100644
--- a/Tactical/XML_Attachments.cpp
+++ b/Tactical/XML_Attachments.cpp
@@ -50,7 +50,7 @@ struct
INT8 szCharData[MAX_CHAR_DATA_LENGTH+1];
- UINT16 curAttachment[2];
+ UINT16 curAttachment[3];
UINT32 maxArraySize;
UINT32 curIndex;
UINT32 currentDepth;
@@ -84,6 +84,7 @@ attachmentStartElementHandle(void *userData, const char *name, const char **atts
}
else if(pData->curElement == ELEMENT &&
(strcmp(name, "attachmentIndex") == 0 ||
+ strcmp(name, "APCost") == 0 ||
strcmp(name, "itemIndex") == 0 ))
{
pData->curElement = ELEMENT_PROPERTY;
@@ -143,6 +144,11 @@ attachmentEndElementHandle(void *userData, const char *name)
pData->curElement = ELEMENT;
pData->curAttachment[1] = (UINT16) atol(pData->szCharData);
}
+ else if(strcmp(name, "APCost") == 0)
+ {
+ pData->curElement = ELEMENT;
+ pData->curAttachment[2] = (UINT16) atol(pData->szCharData);
+ }
pData->maxReadDepth--;
}
@@ -234,6 +240,7 @@ BOOLEAN WriteAttachmentStats()
FilePrintf(hFile,"\t\t%d\r\n", Attachment[cnt][0]);
FilePrintf(hFile,"\t\t%d\r\n", Attachment[cnt][1]);
+ FilePrintf(hFile,"\t\t%d\r\n", Attachment[cnt][2]);
FilePrintf(hFile,"\t\r\n");
}