diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index 4045f0759..413e9b58e 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -5997,12 +5997,12 @@ BOOLEAN BuildFortification( UINT32 flag ) if ( gusSelectedSoldier == NOBODY ) return FALSE; - if( (gTacticalStatus.uiFlags & INCOMBAT) && (gTacticalStatus.uiFlags & TURNBASED) ) + // comment this in to forbid building while enemies are around + /*if( (gTacticalStatus.uiFlags & INCOMBAT) && (gTacticalStatus.uiFlags & TURNBASED) ) { return FALSE; } - - /* // comment this in to forbid building while enemies are around + if( gWorldSectorX != -1 && gWorldSectorY != -1 && gWorldSectorX != 0 && gWorldSectorY != 0 && NumEnemiesInAnySector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) > 0 ) { diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp index b86353c57..12b32d906 100644 --- a/Tactical/Points.cpp +++ b/Tactical/Points.cpp @@ -3481,13 +3481,8 @@ INT16 GetAPsToBuildFortification( SOLDIERTYPE *pSoldier, INT32 usMapPos ) INT16 sAPCost = 0; sAPCost = PlotPath( pSoldier, usMapPos, NO_COPYROUTE, NO_PLOT, TEMPORARY, (UINT16)pSoldier->usUIMovementMode, NOT_STEALTH, FORWARD, pSoldier->bActionPoints ); - - // If point cost is zero, return 0 - if ( sAPCost != 0 ) - { - // ADD APS TO PICKUP - sAPCost += APBPConstants[AP_FORTIFICATION]; - } + + sAPCost += APBPConstants[AP_FORTIFICATION]; return sAPCost; diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 4cf684e36..84fadf9ff 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -14392,6 +14392,11 @@ void SOLDIERTYPE::EVENT_SoldierBuildStructure( INT32 sGridNo, UINT8 ubDirection else this->ChangeSoldierState( CUTTING_FENCE, 0, 0 ); + // ugly, ugly hack: as e do not have a special animation for this action, we use the 'cut a fence' animations + // however, APs are directly deducted because of this. So we can't use the AP_FORTIFICATION costs + // for this reason, we deduct the APS still missing here + INT16 restAPs = max(0, APBPConstants[AP_FORTIFICATION] - APBPConstants[AP_USEWIRECUTTERS]); + if ( HasItemFlag(this->inv[ HANDPOS ].usItem, (FULL_SANDBAG|CONCERTINA)) ) { // Build the thing @@ -14404,6 +14409,8 @@ void SOLDIERTYPE::EVENT_SoldierBuildStructure( INT32 sGridNo, UINT8 ubDirection StatChange( this, STRAMT, 4, TRUE ); StatChange( this, HEALTHAMT, 2, TRUE ); + DeductPoints( this, restAPs, 0, AFTERACTION_INTERRUPT ); + fSuccess = TRUE; } } @@ -14432,8 +14439,31 @@ void SOLDIERTYPE::EVENT_SoldierBuildStructure( INT32 sGridNo, UINT8 ubDirection StatChange( this, STRAMT, 1, TRUE ); StatChange( this, HEALTHAMT, 1, TRUE ); + DeductPoints( this, restAPs, 0, AFTERACTION_INTERRUPT ); + fSuccess = TRUE; } + else + { + fullsandbagnr = 2824; + if ( HasItemFlag(fullsandbagnr, FULL_SANDBAG) ) + { + // Erase 'material' item from our hand - we 'used' it to build the structure + INT8 bObjSlot = HANDPOS; + + CreateItem( fullsandbagnr, 100, &gTempObject ); + + SwapObjs( this, bObjSlot, &gTempObject, TRUE ); + + // we gain a bit of experience... + StatChange( this, STRAMT, 1, TRUE ); + StatChange( this, HEALTHAMT, 1, TRUE ); + + DeductPoints( this, restAPs, 0, AFTERACTION_INTERRUPT ); + + fSuccess = TRUE; + } + } } } } @@ -14458,8 +14488,32 @@ void SOLDIERTYPE::EVENT_SoldierBuildStructure( INT32 sGridNo, UINT8 ubDirection StatChange( this, STRAMT, 3, TRUE ); StatChange( this, HEALTHAMT, 2, TRUE ); + DeductPoints( this, restAPs, 0, AFTERACTION_INTERRUPT ); + fSuccess = TRUE; } + else + { + fullsandbagnr = 2824; + if ( HasItemFlag(fullsandbagnr, FULL_SANDBAG) ) + { + // Erase 'material' item from our hand - we 'used' it to build the structure + INT8 bObjSlot = HANDPOS; + + CreateItem( fullsandbagnr, 100, &gTempObject ); + + // now add a tripwire item to the floor, simulating that activating tripwire deactivates it + AddItemToPool( sGridNo, &gTempObject, 1, 0, 0, -1 ); + + // we gain a bit of experience... + StatChange( this, STRAMT, 3, TRUE ); + StatChange( this, HEALTHAMT, 2, TRUE ); + + DeductPoints( this, restAPs, 0, AFTERACTION_INTERRUPT ); + + fSuccess = TRUE; + } + } } } } diff --git a/Tactical/UI Cursors.cpp b/Tactical/UI Cursors.cpp index f5a328781..a4a74796b 100644 --- a/Tactical/UI Cursors.cpp +++ b/Tactical/UI Cursors.cpp @@ -2162,6 +2162,8 @@ UINT8 HandleFortificationCursor( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT32 ui { return( FORTIFICATION_RED_UICURSOR ); } + else + return( FORTIFICATION_RED_UICURSOR ); } if ( HasItemFlag( (&(pSoldier->inv[HANDPOS]))->usItem, (SHOVEL)) ) @@ -2172,6 +2174,8 @@ UINT8 HandleFortificationCursor( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT32 ui { return( FORTIFICATION_GREY_UICURSOR ); } + else + return( FORTIFICATION_RED_UICURSOR ); } // can we build something here?