diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index cb223d58e..d0ee5fb8f 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -2592,7 +2592,7 @@ void INVRenderINVPanelItem( SOLDIERTYPE *pSoldier, INT16 sPocket, UINT8 fDirtyLe { fHatchItOut = TRUE; } - else if ( !pObject->exists() ) // Nothing in sPocket. Display silouhette. + else if ( !pObject->exists() ) // Nothing in sPocket. Display silhouette. { INVRenderSilhouette( guiSAVEBUFFER, lbePocket, 0, sX, sY, gSMInvData[ sPocket ].sWidth, gSMInvData[ sPocket ].sHeight); } @@ -2632,7 +2632,7 @@ void INVRenderINVPanelItem( SOLDIERTYPE *pSoldier, INT16 sPocket, UINT8 fDirtyLe default: /*if ( pObject->exists() == false ) { - // Display appropriate silouhette + // Display appropriate silhouette }*/ break; } @@ -8302,7 +8302,7 @@ void RenderLBENODEItems( OBJECTTYPE *pObj, int subObject ) if(lbePocket == 0){ // Deactivate Pocket DrawHatchOnInventory( guiSAVEBUFFER, sX, sY, (UINT16)(LBEInvPocketXY[cnt].sWidth-1), (UINT16)(LBEInvPocketXY[cnt].sHeight-1), 0 ); } - else if(pObject == NULL){ // Nothing in sPocket. Display silouhette. + else if(pObject == NULL){ // Nothing in sPocket. Display silhouette. INVRenderSilhouette( guiSAVEBUFFER, lbePocket, 0, sX, sY, LBEInvPocketXY[cnt].sWidth, LBEInvPocketXY[cnt].sHeight); } else if(pObject != NULL){ @@ -8369,10 +8369,12 @@ void DeleteItemDescriptionBox( ) originalIter != gOriginalAttachments.end() && newIter != (*gpItemDescObject)[0]->attachments.end(); ++originalIter, ++newIter) { - if(originalIter->exists()){ + if(originalIter->exists()) + { originalSize++; } - if(newIter->exists()){ + if(newIter->exists()) + { newSize++; } // silversurfer: If we replaced one attachment with another the size will not differ so we need to check content too. @@ -8383,33 +8385,58 @@ void DeleteItemDescriptionBox( ) } } - - if (newSize != originalSize || bAttachmentsDiffer) { + if (newSize != originalSize || bAttachmentsDiffer) + { //an attachment was changed, find the change for (originalIter = gOriginalAttachments.begin(), newIter = (*gpItemDescObject)[0]->attachments.begin(); originalIter != gOriginalAttachments.end() && newIter != (*gpItemDescObject)[0]->attachments.end(); - ++originalIter, ++newIter) { - if (*originalIter == *newIter) { + ++originalIter, ++newIter) + { + if (*originalIter == *newIter) + { continue; } - else { + else + { break; } } - if (newSize < originalSize) { + if (newSize < originalSize) + { //an attachment was removed, charge APs ubAPCost = AttachmentAPCost(originalIter->usItem,gpItemDescObject, gpAttachSoldier ); // SANDRO - added argument } - else { + else + { //an attachment was added charge APs - //lalien: changed to charge AP's for reloading a GL/RL - if ( Item[ gpItemDescObject->usItem ].usItemClass == IC_LAUNCHER || Item[gpItemDescObject->usItem].cannon ) + + // sevenfm: check if we are attaching grenade to launcher + OBJECTTYPE *pLauncher = NULL; + // check if loading GL + if (Item[gpItemDescObject->usItem].usItemClass & IC_WEAPON && Item[newIter->usItem].usItemClass & IC_EXPLOSV) { - ubAPCost = GetAPsToReload( gpItemDescObject ); + for (attachmentList::iterator iter = (*gpItemDescObject)[0]->attachments.begin(); iter != (*gpItemDescObject)[0]->attachments.end(); ++iter) + { + if (iter->exists() && ValidLaunchable(newIter->usItem, iter->usItem)) + { + pLauncher = &(*iter); + } + } + } + + if (Item[gpItemDescObject->usItem].usItemClass == IC_LAUNCHER && ValidLaunchable(newIter->usItem, gpItemDescObject->usItem) || + Item[gpItemDescObject->usItem].cannon) + { + //lalien: changed to charge AP's for reloading a GL/RL + ubAPCost = GetAPsToReload(gpItemDescObject); + } + else if (pLauncher) + { + ubAPCost = GetAPsToReload(pLauncher); } else { - ubAPCost = AttachmentAPCost(newIter->usItem,gpItemDescObject, gpAttachSoldier); // SANDRO - added argument + ubAPCost = AttachmentAPCost(newIter->usItem, gpItemDescObject, gpAttachSoldier); // SANDRO - added argument } } } diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index c95732be4..96a7879ec 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -2301,6 +2301,8 @@ BOOLEAN ValidAttachment( UINT16 usAttachment, OBJECTTYPE * pObj, UINT8 * pubAPCo if( UsingNewAttachmentSystem() ) { + BOOLEAN foundValidAttachment = FALSE; + //It's possible we've entered this function without being passed the usAttachmentSlotIndexVector parameter if(usAttachmentSlotIndexVector.empty()) usAttachmentSlotIndexVector = GetItemSlots(pObj); @@ -2310,7 +2312,7 @@ BOOLEAN ValidAttachment( UINT16 usAttachment, OBJECTTYPE * pObj, UINT8 * pubAPCo return FALSE; //Madd: Common Attachment Framework - if ( pubAPCost && IsAttachmentPointAvailable( pObj, subObject, usAttachment ) ) + if (pubAPCost && IsAttachmentPointAvailable(pObj, subObject, usAttachment)) { *pubAPCost = Item[usAttachment].ubAttachToPointAPCost; @@ -2319,21 +2321,39 @@ BOOLEAN ValidAttachment( UINT16 usAttachment, OBJECTTYPE * pObj, UINT8 * pubAPCo else { //Check if the attachment is valid with the main item - if ( ValidAttachment(usAttachment, pObj->usItem, pubAPCost) || ValidLaunchable(usAttachment, pObj->usItem) ) - return TRUE; + foundValidAttachment = (ValidAttachment(usAttachment, pObj->usItem, pubAPCost) || ValidLaunchable(usAttachment, pObj->usItem)); //Loop through all attachment points on the main item - for(attachmentList::iterator iter = (*pObj)[subObject]->attachments.begin(); iter != (*pObj)[subObject]->attachments.end(); ++iter) + for (attachmentList::iterator iter = (*pObj)[subObject]->attachments.begin(); iter != (*pObj)[subObject]->attachments.end() && !foundValidAttachment; ++iter) { - if ( iter->exists() ) + if (iter->exists()) { - if ( ValidAttachment(usAttachment, iter->usItem, pubAPCost) || ValidLaunchable(usAttachment, iter->usItem) ) - return TRUE; + foundValidAttachment = (ValidAttachment(usAttachment, iter->usItem, pubAPCost) || ValidLaunchable(usAttachment, iter->usItem)); + } + } + + // sevenfm: determine if we attach launchable to launcher + if (foundValidAttachment && pubAPCost) + { + if (Item[pObj->usItem].usItemClass == IC_LAUNCHER && ValidLaunchable(usAttachment, pObj->usItem)) + { + *pubAPCost = GetAPsToReload(pObj); + } + else if (Item[pObj->usItem].usItemClass & IC_WEAPON && Item[usAttachment].usItemClass & IC_EXPLOSV) + { + for (attachmentList::iterator iter_launcher = (*pObj)[0]->attachments.begin(); iter_launcher != (*pObj)[0]->attachments.end(); ++iter_launcher) + { + if (iter_launcher->exists() && ValidLaunchable(usAttachment, iter_launcher->usItem)) + { + *pubAPCost = GetAPsToReload(&(*iter_launcher)); + break; + } + } } } } - return FALSE; + return foundValidAttachment; } return( ValidAttachment(usAttachment, pObj->usItem, pubAPCost) ); @@ -2364,8 +2384,27 @@ UINT8 AttachmentAPCost( UINT16 usAttachment, OBJECTTYPE * pObj, SOLDIERTYPE * pS ValidAttachment(usAttachment, pObj, &ubAPCost, subObject, usAttachmentSlotIndexVector); + BOOLEAN fLaunchable = FALSE; + if (Item[pObj->usItem].usItemClass == IC_LAUNCHER && ValidLaunchable(usAttachment, pObj->usItem)) + { + fLaunchable = TRUE; + } + // sevenfm: different cost when attaching grenade to attached launcher + else if (Item[pObj->usItem].usItemClass & IC_WEAPON && Item[usAttachment].usItemClass & IC_EXPLOSV) + { + OBJECTTYPE *pLauncher; + for (attachmentList::iterator iter = (*pObj)[0]->attachments.begin(); iter != (*pObj)[0]->attachments.end(); ++iter) + { + if (iter->exists() && ValidLaunchable(usAttachment, iter->usItem)) + { + fLaunchable = TRUE; + } + } + } + // SANDRO - STOMP traits - Ambidextrous attaching objects speed bonus - if ( pSoldier != NULL ) + // sevenfm: don't apply when attaching launchable to launcher + if (pSoldier != NULL && !fLaunchable) { if ( gGameOptions.fNewTraitSystem && HAS_SKILL_TRAIT( pSoldier, AMBIDEXTROUS_NT ) ) { @@ -3669,7 +3708,11 @@ BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo if ( usReloadSound != 0 && !IsAutoResolveActive() ) { - PlayJA2Sample( usReloadSound, RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); + // sevenfm: set volume and pan based on soldier's gridno when reloading + if (!TileIsOutOfBounds(pSoldier->sGridNo)) + PlayJA2Sample(usReloadSound, RATE_11025, SoundVolume((INT8)HIGHVOLUME, pSoldier->sGridNo), 1, SoundDir(pSoldier->sGridNo)); + else + PlayJA2Sample( usReloadSound, RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); } }