mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
-externalized AP costs for attachments or an attachment-by-attachment basis
-added APCost to Attachments.xml git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@475 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
+20
-2
@@ -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).
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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<attachmentIndex>%d</attachmentIndex>\r\n", Attachment[cnt][0]);
|
||||
FilePrintf(hFile,"\t\t<itemIndex>%d</itemIndex>\r\n", Attachment[cnt][1]);
|
||||
FilePrintf(hFile,"\t\t<APCost>%d</APCost>\r\n", Attachment[cnt][2]);
|
||||
|
||||
FilePrintf(hFile,"\t</ATTACHMENT>\r\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user