From 544314276ca3d028f3321195a9d07cd707d26164 Mon Sep 17 00:00:00 2001 From: Flugente Date: Wed, 22 Aug 2012 19:54:35 +0000 Subject: [PATCH] - grenaded can now also be armed in the inventory like bombs - fix: underbarrel weapons no longer influence dirt generation git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5492 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameSettings.cpp | 7 +- Init.h | 1 + Tactical/Interface Items.cpp | 128 +++++++++++++++++++++++++---------- Tactical/Items.cpp | 3 +- Tactical/Soldier Control.cpp | 2 +- 5 files changed, 101 insertions(+), 40 deletions(-) diff --git a/GameSettings.cpp b/GameSettings.cpp index 0e77d35a..8d8ea0f9 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -2437,9 +2437,10 @@ void LoadGameAPBPConstants() APBPConstants[AP_JUMPWALL] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_JUMPOFFWALL",40),40); APBPConstants[AP_JUMPOFFWALL] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_JUMPWALL",24),24); - APBPConstants[AP_FORTIFICATION] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_FORTIFICATION",80),80); - APBPConstants[AP_EAT] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_EAT",80),80); - APBPConstants[AP_CLEANINGKIT] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_CLEANINGKIT",80),80); + APBPConstants[AP_FORTIFICATION] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_FORTIFICATION",80),80); + APBPConstants[AP_EAT] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_EAT",80),80); + APBPConstants[AP_CLEANINGKIT] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_CLEANINGKIT",80),80); + APBPConstants[AP_INVENTORY_EXPLOSIVE_ACTIVATE] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_INVENTORY_EXPLOSIVE_ACTIVATE",20),20); SetupMaxActionPointsAnimation(); #undef ReadInteger diff --git a/Init.h b/Init.h index 8408bab4..4b18f71b 100644 --- a/Init.h +++ b/Init.h @@ -200,6 +200,7 @@ AP_JUMPOFFWALL, AP_FORTIFICATION, AP_EAT, AP_CLEANINGKIT, +AP_INVENTORY_EXPLOSIVE_ACTIVATE, TOTAL_APBP_VALUES }; #endif diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 04b90a5f..6487b190 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -6566,10 +6566,22 @@ void RenderItemDescriptionBox( ) break; } - if ( (Transform[x].usItem == gpItemDescObject->usItem) || ( (guiCurrentScreen == GAME_SCREEN) || (guiCurrentScreen == MAP_SCREEN) ) && Item[gpItemDescObject->usItem].usItemClass == IC_BOMB && gpItemDescObject->ubNumberOfObjects == 1 && HasAttachmentOfClass( gpItemDescObject, (AC_DETONATOR | AC_REMOTEDET) ) ) + // Flugente: ok, this looks complicated. We allow a transformation option to pop up if: + // - there is a transformation + // - we are in the game or map screen, it is a single item, and + // - the item is a grenade + // - the item is a bomb and has a detonator or remote detonator attached + if ( Transform[x].usItem == gpItemDescObject->usItem ) { BltVideoObjectFromIndex( guiSAVEBUFFER, guiTransformIconGraphic, 0, (ITEMDESC_ITEM_X+ITEMDESC_ITEM_WIDTH)-13, (ITEMDESC_ITEM_Y+ITEMDESC_ITEM_HEIGHT)-17, VO_BLT_SRCTRANSPARENCY, NULL ); } + else if ( (guiCurrentScreen == GAME_SCREEN || guiCurrentScreen == MAP_SCREEN) && gpItemDescObject->ubNumberOfObjects == 1 ) + { + if ( (Item[gpItemDescObject->usItem].usItemClass == IC_GRENADE) || ( (Item[gpItemDescObject->usItem].usItemClass == IC_BOMB) && HasAttachmentOfClass( gpItemDescObject, (AC_DETONATOR | AC_REMOTEDET)) ) ) + { + BltVideoObjectFromIndex( guiSAVEBUFFER, guiTransformIconGraphic, 0, (ITEMDESC_ITEM_X+ITEMDESC_ITEM_WIDTH)-13, (ITEMDESC_ITEM_Y+ITEMDESC_ITEM_HEIGHT)-17, VO_BLT_SRCTRANSPARENCY, NULL ); + } + } } } @@ -12730,58 +12742,84 @@ void ItemDescTransformRegionCallback( MOUSE_REGION *pRegion, INT32 reason ) // Flugente: we can also arm/disarm bombs in our inventory via this menu BOOLEAN fHaveToDisarm = FALSE; // important check: if item is an armed bomb, we have to disarm it prior to any transformation - if ( ( (guiCurrentScreen == GAME_SCREEN) || (guiCurrentScreen == MAP_SCREEN) ) && Item[gpItemDescObject->usItem].usItemClass == IC_BOMB && gpItemDescObject->ubNumberOfObjects == 1 && HasAttachmentOfClass( gpItemDescObject, (AC_DETONATOR | AC_REMOTEDET) ) ) + if ( ((guiCurrentScreen == GAME_SCREEN) || (guiCurrentScreen == MAP_SCREEN)) && gpItemDescObject->ubNumberOfObjects == 1 ) { - iTransformIndex++; - - UINT16 apcost = 20; - - if ( (guiCurrentScreen == GAME_SCREEN) || (guiCurrentScreen == MAP_SCREEN) ) - apcost = 15; - - // test wether item is already armed - INT8 detonatortype; - INT8 setting; - INT8 defusefrequency; - CheckBombSpecifics( gpItemDescObject, &detonatortype, &setting, &defusefrequency ); - - CHAR16 MenuRowText[300]; - - if ( detonatortype == BOMB_TIMED || detonatortype == BOMB_REMOTE ) + if ( Item[gpItemDescObject->usItem].usItemClass == IC_BOMB && HasAttachmentOfClass( gpItemDescObject, (AC_DETONATOR | AC_REMOTEDET)) ) { - fHaveToDisarm = TRUE; + iTransformIndex++; + + UINT16 apcost = APBPConstants[AP_INVENTORY_EXPLOSIVE_ACTIVATE]; - if ( apcost > 0 && gTacticalStatus.uiFlags & INCOMBAT && gTacticalStatus.uiFlags & TURNBASED ) + // test wether item is already armed + INT8 detonatortype; + INT8 setting; + INT8 defusefrequency; + CheckBombSpecifics( gpItemDescObject, &detonatortype, &setting, &defusefrequency ); + + CHAR16 MenuRowText[300]; + + if ( detonatortype == BOMB_TIMED || detonatortype == BOMB_REMOTE ) { - swprintf (MenuRowText, L"Disarm (%d AP)", apcost ); + fHaveToDisarm = TRUE; + + if ( apcost > 0 && gTacticalStatus.uiFlags & INCOMBAT && gTacticalStatus.uiFlags & TURNBASED ) + { + swprintf (MenuRowText, L"Disarm (%d AP)", apcost ); + } + else + { + swprintf (MenuRowText, L"Disarm"); + } } else { - swprintf (MenuRowText, L"Disarm"); + if ( apcost > 0 && gTacticalStatus.uiFlags & INCOMBAT && gTacticalStatus.uiFlags & TURNBASED ) + { + swprintf (MenuRowText, L"Arm (%d AP)", apcost ); + } + else + { + swprintf (MenuRowText, L"Arm"); + } } + + // Generate a new option for the menu + POPUP_OPTION *pOption = new POPUP_OPTION(&std::wstring( MenuRowText ), new popupCallbackFunction( &TransformationMenuPopup_Arm, gpItemDescObject ) ); + // Set the function that tests whether it's valid at the moment. + pOption->setAvail(new popupCallbackFunction( &TransformationMenuPopup_Arm_TestValid, gpItemDescObject )); + // Add the option to the menu. + gItemDescTransformPopup->addOption( *pOption ); + // Set this flag so we know we have at least one Transformation available. + fFoundTransformations = true; } - else + else if ( Item[gpItemDescObject->usItem].usItemClass == IC_GRENADE ) { + iTransformIndex++; + + UINT16 apcost = 20; + + CHAR16 MenuRowText[300]; + if ( apcost > 0 && gTacticalStatus.uiFlags & INCOMBAT && gTacticalStatus.uiFlags & TURNBASED ) { - swprintf (MenuRowText, L"Arm (%d AP)", apcost ); + swprintf (MenuRowText, L"Blow up (%d AP)", apcost ); } else { - swprintf (MenuRowText, L"Arm"); + swprintf (MenuRowText, L"Blow up"); } - } - // Generate a new option for the menu - POPUP_OPTION *pOption = new POPUP_OPTION(&std::wstring( MenuRowText ), new popupCallbackFunction( &TransformationMenuPopup_Arm, gpItemDescObject ) ); - // Set the function that tests whether it's valid at the moment. - pOption->setAvail(new popupCallbackFunction( &TransformationMenuPopup_Arm_TestValid, gpItemDescObject )); - // Add the option to the menu. - gItemDescTransformPopup->addOption( *pOption ); - // Set this flag so we know we have at least one Transformation available. - fFoundTransformations = true; + // Generate a new option for the menu + POPUP_OPTION *pOption = new POPUP_OPTION(&std::wstring( MenuRowText ), new popupCallbackFunction( &TransformationMenuPopup_Arm, gpItemDescObject ) ); + // Set the function that tests whether it's valid at the moment. + pOption->setAvail(new popupCallbackFunction( &TransformationMenuPopup_Arm_TestValid, gpItemDescObject )); + // Add the option to the menu. + gItemDescTransformPopup->addOption( *pOption ); + // Set this flag so we know we have at least one Transformation available. + fFoundTransformations = true; + } } - + // onyl allow transformations if the item is not an armed bomb if ( !fHaveToDisarm ) { @@ -12961,6 +12999,26 @@ void TransformationMenuPopup_Arm( OBJECTTYPE* pObj ) if ( screen != GAME_SCREEN && screen != MAP_SCREEN ) return; + // if this is grenade, blow it up, no dialogue settings here + if ( Item[pObj->usItem].usItemClass == IC_GRENADE ) + { + INT8 screen = guiCurrentScreen; + if ( screen == GAME_SCREEN ) + { + // ignite explosions manually - this item is not in the WorldBombs-structure, so we can't add it to the queue + IgniteExplosion( (*pObj)[0]->data.misc.ubBombOwner - 2, gpItemDescSoldier->sX, gpItemDescSoldier->sY, (INT16) (gpWorldLevelData[gpItemDescSoldier->sGridNo].sHeight), gpItemDescSoldier->sGridNo, pObj->usItem, gpItemDescSoldier->pathing.bLevel, gpItemDescSoldier->ubDirection ); + } + else + { + // no explosions in map screen - instead we simply damage the inventory and harm our health + gpItemDescSoldier->InventoryExplosion(); + } + + DeleteObj( pObj ); + + return; + } + // test wether item is already armed INT8 detonatortype; INT8 setting; diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 7e0acda3..8d420637 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -14385,7 +14385,8 @@ FLOAT GetItemDirtIncreaseFactor( OBJECTTYPE * pObj, BOOLEAN fConsiderAmmo ) attachmentList::iterator iterend = (*pObj)[0]->attachments.end(); for (attachmentList::iterator iter = (*pObj)[0]->attachments.begin(); iter != iterend; ++iter) { - if (iter->exists()) + // it attachment is not a weapon, add its factor + if (iter->exists() && !(Item[iter->usItem].usItemClass & IC_WEAPON) ) { dirtincreasefactor += Item[iter->usItem].dirtIncreaseFactor; } diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 106846a1..0a23bf79 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -14332,7 +14332,7 @@ OBJECTTYPE* SOLDIERTYPE::GetCleaningKit() void SOLDIERTYPE::CleanWeapon() { // in turnbased, this action costs APs. remove them if possible, otherwise, return - INT16 apcost = APBPConstants[AP_FORTIFICATION]; + INT16 apcost = APBPConstants[AP_CLEANINGKIT]; if ( gTacticalStatus.uiFlags & TURNBASED ) {