From 376b174d5b712cebee5c1ff418e01c500f4658eb Mon Sep 17 00:00:00 2001 From: Wanne Date: Sun, 24 Nov 2013 11:01:45 +0000 Subject: [PATCH] Small convenience feature - improved bomb planting (by Sevenfm) - With new option IMPROVED_BOMB_PLANTING = TRUE, if you hold SHIFT key while planting new mine, then another mine with same item id will be taken automatically from your merc's inventory. If no such item found, any mine will be taken. If you plant tripwire-triggered mine, then only tripwire-triggered items will be taken. This new feature work only in realtime. If you are making tripwire network, then this feature can be used to plant another tripwire item with network and hierarchy settings taken from previously planted tripwire. You just plant tripwire as usual, selecting it's settings from dialogue, then if you plant another one while holding SHIFT key, those settings will be used for new tripwire, instead of showing you dialogue - I hope this small improvement will save you some time for building large and complicated defensive minefields. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6647 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameSettings.cpp | 3 +++ GameSettings.h | 1 + Tactical/Handle Items.cpp | 27 +++++++++++++++++----- Tactical/Soldier Control.cpp | 43 ++++++++++++++++++++++++++++++++++++ Tactical/Soldier Control.h | 3 +++ 5 files changed, 72 insertions(+), 5 deletions(-) diff --git a/GameSettings.cpp b/GameSettings.cpp index b7d66ca8..4667eedc 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -1352,6 +1352,9 @@ void LoadGameExternalOptions() // , and add special bonuses to explosion gGameExternalOptions.bAllowSpecialExplosiveAttachments = iniReader.ReadBoolean("Tactical Interface Settings","ALLOW_SPECIAL_EXPLOSIVE_ATTACHMENTS",FALSE); + // Automatically take new mine from inventory, use last tripwire network settings + gGameExternalOptions.bImprovedBombPlanting = iniReader.ReadBoolean("Tactical Interface Settings","IMPROVED_BOMB_PLANTING",FALSE); + // Chance to Say Annoying Phrase (you can just turn of it by button in game) gGameExternalOptions.iChanceSayAnnoyingPhrase = iniReader.ReadInteger("Tactical Interface Settings","CHANCE_SAY_ANNOYING_PHRASE",100); diff --git a/GameSettings.h b/GameSettings.h index 9b68bd6f..4e903d9d 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -796,6 +796,7 @@ typedef struct BOOLEAN bAddSmokeAfterExplosion; BOOLEAN bAllowExplosiveAttachments; BOOLEAN bAllowSpecialExplosiveAttachments; + BOOLEAN bImprovedBombPlanting; INT16 iChanceSayAnnoyingPhrase; BOOLEAN bNewTacticalAIBehavior; FLOAT uShotHeadPenalty; diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index adda3a5f..384d8c11 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -65,6 +65,8 @@ // added by Flugente #include "drugs and alcohol.h" #include "Food.h" + // added by sevenfm - this is needed for _keydown(SHIFT) to work + #include "english.h" #endif #ifdef JA2UB @@ -79,6 +81,8 @@ ITEM_POOL_LOCATOR FlashItemSlots[ NUM_ITEM_FLASH_SLOTS ]; UINT32 guiNumFlashItemSlots = 0; +// sevenfm: remember network settings for last planted tripwire +UINT8 gubLastTripwire = 0; LEVELNODE *AddItemGraphicToWorld( INVTYPE *pItem, INT32 sGridNo, UINT8 ubLevel ); @@ -1820,12 +1824,17 @@ void HandleSoldierDropBomb( SOLDIERTYPE *pSoldier, INT32 sGridNo ) gTempObject[0]->data.bDefuseFrequency = 0; // we now know there is something nasty here - // sevenfm: do not add mine present flag if remote detonator attached - if(! HasAttachmentOfClass( &(pSoldier->inv[ HANDPOS ] ), (AC_REMOTEDET | AC_DEFUSE) ) ) - gpWorldLevelData[ sGridNo ].uiFlags |= MAPELEMENT_PLAYER_MINE_PRESENT; + gpWorldLevelData[ sGridNo ].uiFlags |= MAPELEMENT_PLAYER_MINE_PRESENT; if (pSoldier->inv[ HANDPOS ].MoveThisObjectTo(gTempObject, 1) == 0) { AddItemToPool( sGridNo, &gTempObject, BURIED, pSoldier->pathing.bLevel, WORLD_ITEM_ARMED_BOMB, 0 ); + // sevenfm: take another item with same id from inventory, only REALTIME + if(gGameExternalOptions.bImprovedBombPlanting && + !( (gTacticalStatus.uiFlags & TURNBASED ) && (gTacticalStatus.uiFlags & INCOMBAT) ) && + !pSoldier->inv[HANDPOS].exists() && _KeyDown( SHIFT )) + { + pSoldier->TakeNewBombFromIventory(gTempObject.usItem); + } } } else @@ -4877,8 +4886,12 @@ void StartBombMessageBox( SOLDIERTYPE * pSoldier, INT32 sGridNo ) wcscpy( gzUserDefinedButton[13], L"4-B" ); wcscpy( gzUserDefinedButton[14], L"4-C" ); wcscpy( gzUserDefinedButton[15], L"4-D" ); - - DoMessageBox( MSG_BOX_BASIC_SMALL_BUTTONS, TacticalStr[ CHOOSE_TRIPWIRE_NETWORK ], GAME_SCREEN, MSG_BOX_FLAG_GENERIC_SIXTEEN_BUTTONS, BombMessageBoxCallBack, NULL ); + + // sevenfm: if SHIFT is pressed - plant tripwire with last network settings + if( gGameExternalOptions.bImprovedBombPlanting && _KeyDown( SHIFT ) && gubLastTripwire > 0 ) + BombMessageBoxCallBack(gubLastTripwire); + else + DoMessageBox( MSG_BOX_BASIC_SMALL_BUTTONS, TacticalStr[ CHOOSE_TRIPWIRE_NETWORK ], GAME_SCREEN, MSG_BOX_FLAG_GENERIC_SIXTEEN_BUTTONS, BombMessageBoxCallBack, NULL ); } } @@ -4971,6 +4984,10 @@ void BombMessageBoxCallBack( UINT8 ubExitValue ) { if (gpTempSoldier) { + // sevenfm: remember last tripwire network settings + if(Item[ gpTempSoldier->inv[HANDPOS].usItem ].tripwire ) + gubLastTripwire = ubExitValue; + if (Item[ gpTempSoldier->inv[HANDPOS].usItem ].remotetrigger ) { SetOffBombsByFrequency( gpTempSoldier->ubID, ubExitValue ); diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 44f22ae6..6e706a56 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -16209,6 +16209,49 @@ void SOLDIERTYPE::DropSectorEquipment() } } +// sevenfm: take item from inventory to HANDPOS +void SOLDIERTYPE::TakeNewBombFromIventory(UINT16 item) +{ + INT8 i; + OBJECTTYPE* pObj = NULL; + INT8 invsize = (INT8)this->inv.size(); + + if ( !UsingNewInventorySystem() ) + return; + + if(this->inv[HANDPOS].exists()) + return; + + if(Item[item].tripwire) + return; + + // search for item with same id + for ( i = 0; i < invsize; i++) + { + if ( ( this->inv[i].exists() == true ) && ( this->inv[i].usItem == item ) ) + { + this->inv[i].MoveThisObjectTo(this->inv[HANDPOS], 1, this); + return; + } + } + + // search for any item with class IC_BOMB + // take tripwire-activated item only if used item is tripwire activated + for ( i = 0; i < invsize; i++) + { + if ( this->inv[i].exists() == true && + Item[ this->inv[i].usItem ].usItemClass == IC_BOMB && + Item[ this->inv[i].usItem ].ubCursor == BOMBCURS && + !Item[ this->inv[i].usItem ].tripwire && + ( ( Item[ this->inv[i].usItem ].tripwireactivation && Item[item].tripwireactivation ) || + ( !Item[ this->inv[i].usItem ].tripwireactivation && !Item[item].tripwireactivation ) ) ) + { + this->inv[i].MoveThisObjectTo(this->inv[HANDPOS], 1, this); + return; + } + } +} + // Flugente: switch hand item for gunsling weapon, or pistol, or knife void SOLDIERTYPE::SwitchWeapons( BOOLEAN fKnife, BOOLEAN fSideArm ) { diff --git a/Tactical/Soldier Control.h b/Tactical/Soldier Control.h index 60ffd059..303765c1 100644 --- a/Tactical/Soldier Control.h +++ b/Tactical/Soldier Control.h @@ -1726,6 +1726,9 @@ public: void DropSectorEquipment(); + // sevenfm: Take new bomb with id = usItem from iventory to HANDPOS + void TakeNewBombFromIventory(UINT16 usItem); + // Flugente: switch hand item for gunsling weapon, or pistol, or knife void SwitchWeapons( BOOLEAN fKnife = FALSE, BOOLEAN fSideArm = FALSE );