From 1435e4a679b3164c594dd904a85df1e1335beb7a Mon Sep 17 00:00:00 2001 From: Flugente Date: Fri, 29 Mar 2013 22:32:13 +0000 Subject: [PATCH] - Fix: applying canteens/camo/clothes on persons still cost them APs - Fix: planting bombs was impossible git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5964 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Handle Items.cpp | 7 ++++- Tactical/Interface Panels.cpp | 2 +- Tactical/Items.cpp | 52 +++++++++++++++++++---------------- Tactical/Items.h | 6 ++-- Tactical/Soldier Control.cpp | 39 ++++++++++++++++++-------- Tactical/UI Cursors.cpp | 16 ++++++++++- 6 files changed, 80 insertions(+), 42 deletions(-) diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index 86dc2487d..b786588ad 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -1331,7 +1331,12 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bLevel, UINT16 usHa sAPCost = GetAPsToApplyItem( pSoldier, sActionGridNo ); sAPCost += PlotPath( pSoldier, sActionGridNo, NO_COPYROUTE, FALSE, TEMPORARY, (UINT16)pSoldier->usUIMovementMode, NOT_STEALTH, FORWARD, pSoldier->bActionPoints); - if ( EnoughPoints( pSoldier, sAPCost, 0, fFromUI ) ) + // if we are at the action gridno, the item is a bomb, but nobody is at the gridno, do not apply and do not return - we will plant the bomb instead (handlded later in this function) + if ( Item[ usHandItem ].usItemClass == IC_BOMB && pSoldier->sGridNo == sActionGridNo && WhoIsThere2( usMapPos, pSoldier->pathing.bLevel ) == NOBODY ) + { + ; + } + else if ( EnoughPoints( pSoldier, sAPCost, 0, fFromUI ) ) { // OK, set UI SetUIBusy( pSoldier->ubID ); diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index 52d8fc428..781f4ed93 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -3375,7 +3375,7 @@ void SMInvClickCamoCallback( MOUSE_REGION * pRegion, INT32 iReason ) gpSMCurrentMerc->DoMercBattleSound( BATTLE_SOUND_COOL1 ); } } - else if ( !gGameOptions.fFoodSystem && ApplyCanteen( gpSMCurrentMerc, gpItemPointer, &fGoodAPs ) ) + else if ( !gGameOptions.fFoodSystem && ApplyCanteen( gpSMCurrentMerc, gpItemPointer, &fGoodAPs, TRUE ) ) { // Dirty if ( fGoodAPs ) diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index e4e5eb2c0..f4e449c48 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -8956,7 +8956,7 @@ void WaterDamage( SOLDIERTYPE *pSoldier ) DirtyMercPanelInterface( pSoldier, DIRTYLEVEL2 ); } -BOOLEAN ApplyCammo( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAPs ) +BOOLEAN ApplyCammo( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAPs, BOOLEAN fUseAPs ) { // Added - SANDRO INT8 bPointsToUse; @@ -8972,7 +8972,7 @@ BOOLEAN ApplyCammo( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAP // added possibility to remove all camo by using a rag on self - SANDRO if ( HasItemFlag(pObj->usItem, CAMO_REMOVAL) && gGameExternalOptions.fCamoRemoving) { - if (!EnoughPoints( pSoldier, (APBPConstants[AP_CAMOFLAGE]/2), 0, TRUE ) ) + if ( fUseAPs && !EnoughPoints( pSoldier, (APBPConstants[AP_CAMOFLAGE]/2), 0, TRUE ) ) { (*pfGoodAPs) = FALSE; return( TRUE ); @@ -8983,7 +8983,8 @@ BOOLEAN ApplyCammo( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAP // damage the rag :) - actually you would need to flag it damagable in the items.XML DamageItem( pObj, 22, FALSE ); - DeductPoints( pSoldier, (APBPConstants[AP_CAMOFLAGE] / 2), 0 ); + if ( fUseAPs ) + DeductPoints( pSoldier, (APBPConstants[AP_CAMOFLAGE] / 2), 0 ); // Reload palettes.... if ( pSoldier->bInSector ) @@ -8998,9 +8999,9 @@ BOOLEAN ApplyCammo( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAP } ////////////////////////////////////////////////////////////////////////////// - if (!EnoughPoints( pSoldier, APBPConstants[AP_CAMOFLAGE], 0, TRUE ) ) + if ( fUseAPs && !EnoughPoints( pSoldier, APBPConstants[AP_CAMOFLAGE], 0, TRUE ) ) { - (*pfGoodAPs) = FALSE; + (*pfGoodAPs) = FALSE; return( TRUE ); } @@ -9221,7 +9222,8 @@ BOOLEAN ApplyCammo( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAP UseKitPoints( pObj, bPointsToUse, pSoldier ); - DeductPoints( pSoldier, APBPConstants[AP_CAMOFLAGE], 0 ); + if ( fUseAPs ) + DeductPoints( pSoldier, APBPConstants[AP_CAMOFLAGE], 0 ); // Reload palettes.... if ( pSoldier->bInSector ) @@ -9233,7 +9235,7 @@ BOOLEAN ApplyCammo( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAP } // Flugente: apply clothes, and eventually disguise -BOOLEAN ApplyClothes( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj) +BOOLEAN ApplyClothes( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fUseAPs ) { // this will only work with the new trait system if (!gGameOptions.fNewTraitSystem) @@ -9248,7 +9250,7 @@ BOOLEAN ApplyClothes( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj) UINT8 skilllevel = NUM_SKILL_TRAITS( pSoldier, COVERT_NT ); INT16 apcost = (APBPConstants[AP_DISGUISE] * ( 100 - gSkillTraitValues.sCODisguiseAPReduction * skilllevel))/100; - if ( !EnoughPoints( pSoldier, apcost, 0, TRUE ) ) + if ( fUseAPs && !EnoughPoints( pSoldier, apcost, 0, TRUE ) ) { ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szCovertTextStr[STR_COVERT_NOT_ENOUGH_APS] ); return( FALSE ); @@ -9339,7 +9341,8 @@ BOOLEAN ApplyClothes( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj) UseKitPoints( pObj, 100, pSoldier ); - DeductPoints( pSoldier, apcost, 0 ); + if ( fUseAPs ) + DeductPoints( pSoldier, apcost, 0 ); } if ( pSoldier->bSoldierFlagMask & SOLDIER_NEW_VEST && pSoldier->bSoldierFlagMask & SOLDIER_NEW_PANTS ) @@ -9375,7 +9378,7 @@ BOOLEAN ApplyClothes( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj) return( TRUE ); } -BOOLEAN ApplyCanteen( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAPs ) +BOOLEAN ApplyCanteen( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAPs, BOOLEAN fUseAPs ) { INT16 sPointsToUse; UINT16 usTotalKitPoints; @@ -9394,28 +9397,29 @@ BOOLEAN ApplyCanteen( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGood return( FALSE ); } - if (!EnoughPoints( pSoldier, APBPConstants[AP_DRINK], 0, TRUE ) ) + if ( fUseAPs && !EnoughPoints( pSoldier, APBPConstants[AP_DRINK], 0, TRUE ) ) { - (*pfGoodAPs) = FALSE; + (*pfGoodAPs) = FALSE; return( TRUE ); } - if ( pSoldier->bTeam == gbPlayerNum ) - { - if ( gMercProfiles[ pSoldier->ubProfile ].bSex == MALE ) - { - PlayJA2Sample( DRINK_CANTEEN_MALE, RATE_11025, MIDVOLUME, 1, MIDDLEPAN ); - } - else - { - PlayJA2Sample( DRINK_CANTEEN_FEMALE, RATE_11025, MIDVOLUME, 1, MIDDLEPAN ); - } - } + if ( pSoldier->bTeam == gbPlayerNum ) + { + if ( gMercProfiles[ pSoldier->ubProfile ].bSex == MALE ) + { + PlayJA2Sample( DRINK_CANTEEN_MALE, RATE_11025, MIDVOLUME, 1, MIDDLEPAN ); + } + else + { + PlayJA2Sample( DRINK_CANTEEN_FEMALE, RATE_11025, MIDVOLUME, 1, MIDDLEPAN ); + } + } sPointsToUse = __min( 20, usTotalKitPoints ); // CJC Feb 9. Canteens don't seem effective enough, so doubled return from them - DeductPoints( pSoldier, APBPConstants[AP_DRINK], (INT16) (2 * sPointsToUse * -(100 - pSoldier->bBreath) ) ); + if ( fUseAPs ) + DeductPoints( pSoldier, APBPConstants[AP_DRINK], (INT16) (2 * sPointsToUse * -(100 - pSoldier->bBreath) ) ); UseKitPoints( pObj, sPointsToUse, pSoldier ); diff --git a/Tactical/Items.h b/Tactical/Items.h index 56d1e3915..3cf2b328e 100644 --- a/Tactical/Items.h +++ b/Tactical/Items.h @@ -195,8 +195,8 @@ void WaterDamage( SOLDIERTYPE *pSoldier ); INT8 FindObj( SOLDIERTYPE * pSoldier, UINT16 usItem, INT8 bLower = 0, INT8 bUpper = NUM_INV_SLOTS ); -BOOLEAN ApplyCammo( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAPs ); -BOOLEAN ApplyClothes( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj); // Flugente: apply clothes, and eventually disguise +BOOLEAN ApplyCammo( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAPs, BOOLEAN fUseAPs = TRUE ); +BOOLEAN ApplyClothes( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fUseAPs = TRUE ); // Flugente: apply clothes, and eventually disguise UINT32 ConvertProfileMoneyValueToObjectTypeMoneyValue( UINT8 ubStatus ); UINT8 ConvertObjectTypeMoneyValueToProfileMoneyValue( UINT32 uiMoneyAmount ); @@ -211,7 +211,7 @@ UINT16 FindReplacementMagazineIfNecessary( UINT16 usOldGun, UINT16 usOldAmmo, UI BOOLEAN DamageItemOnGround( OBJECTTYPE * pObject, INT32 sGridNo, INT8 bLevel, INT32 iDamage, UINT8 ubOwner ); -BOOLEAN ApplyCanteen( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAPs ); +BOOLEAN ApplyCanteen( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAPs, BOOLEAN fUseAPs = TRUE ); BOOLEAN ApplyElixir( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN *pfGoodAPs ); BOOLEAN CompatibleFaceItem( UINT16 usItem1, UINT16 usItem2 ); diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 465286818..6f0b5d501 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -16985,15 +16985,15 @@ void SOLDIERTYPE::EVENT_SoldierApplyItemToPerson( INT32 sGridNo, UINT8 ubDirecti { this->LooseDisguise(); this->Strip(); - - // alert the soldier - pSoldier->aiData.bAlertStatus = min(pSoldier->aiData.bAlertStatus, STATUS_RED); - - ProcessImplicationsOfPCAttack( this, &pSoldier, REASON_NORMAL_ATTACK ); - + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szCovertTextStr[STR_COVERT_APPLYITEM_STEAL_FAIL], this->name, pSoldier->name ); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szCovertTextStr[STR_COVERT_UNCOVERED], pSoldier->name, this->name ); } + + // alert the soldier + pSoldier->aiData.bAlertStatus = min(pSoldier->aiData.bAlertStatus, STATUS_RED); + + ProcessImplicationsOfPCAttack( this, &pSoldier, REASON_NORMAL_ATTACK ); } } @@ -17002,7 +17002,7 @@ void SOLDIERTYPE::EVENT_SoldierApplyItemToPerson( INT32 sGridNo, UINT8 ubDirecti if ( !gGameOptions.fFoodSystem && Item[ usItem ].canteen ) { BOOLEAN tmp = FALSE; - success = ApplyCanteen( pSoldier, pObj, &tmp ); + success = ApplyCanteen( pSoldier, pObj, &tmp, FALSE ); } else if ( Item[ usItem ].drugtype || Item[ usItem ].canteen ) { @@ -17012,7 +17012,7 @@ void SOLDIERTYPE::EVENT_SoldierApplyItemToPerson( INT32 sGridNo, UINT8 ubDirecti else if ( Item[ usItem ].camouflagekit ) { BOOLEAN tmp = FALSE; - success = ApplyCammo( pSoldier, pObj, &tmp ); + success = ApplyCammo( pSoldier, pObj, &tmp, FALSE ); if ( success ) { @@ -17055,7 +17055,7 @@ void SOLDIERTYPE::EVENT_SoldierApplyItemToPerson( INT32 sGridNo, UINT8 ubDirecti } else if ( Item[ usItem ].clothestype ) { - ApplyClothes( pSoldier, pObj ); + ApplyClothes( pSoldier, pObj, FALSE ); // Dirty fInterfacePanelDirty = DIRTYLEVEL2; @@ -17083,10 +17083,25 @@ void SOLDIERTYPE::EVENT_SoldierApplyItemToPerson( INT32 sGridNo, UINT8 ubDirecti return; } - } - // Say NOTHING quote... - this->DoMercBattleSound( BATTLE_SOUND_NOTHING ); + // Say NOTHING quote... + this->DoMercBattleSound( BATTLE_SOUND_NOTHING ); + } + else + { + // if this is bomb, but nobody is there, plant the bomb instead + OBJECTTYPE* pObj = &(this->inv[ HANDPOS ]); + + if ( pObj->exists() ) + { + UINT16 usItem = pObj->usItem; + + if ( Item[ usItem ].usItemClass == IC_BOMB ) + { + this->EVENT_SoldierBeginDropBomb( ); + } + } + } } void SOLDIERTYPE::EVENT_SoldierBeginReloadRobot( INT32 sGridNo, UINT8 ubDirection, UINT8 ubMercSlot ) diff --git a/Tactical/UI Cursors.cpp b/Tactical/UI Cursors.cpp index 85c2307c5..8cc65f78e 100644 --- a/Tactical/UI Cursors.cpp +++ b/Tactical/UI Cursors.cpp @@ -2740,7 +2740,21 @@ UINT8 GetActionModeCursor( SOLDIERTYPE *pSoldier ) // Flugente: apply misc items to other soldiers if ( ItemCanBeAppliedToOthers( usInHand ) ) - ubCursor = APPLYITEMCURS; + { + // if item is a bomb, only allow apply if hovering over a soldier (otherwise we cannot mine anymore) + if ( Item[ usInHand ].usItemClass == IC_BOMB ) + { + INT32 usMapPos = NOWHERE; + if ( GetMouseMapPos( &usMapPos ) ) + { + // is there a person here? + if ( WhoIsThere2( usMapPos, pSoldier->pathing.bLevel ) != NOBODY ) + ubCursor = APPLYITEMCURS; + } + } + else + ubCursor = APPLYITEMCURS; + } // Now check our terrain to see if we cannot do the action now... if ( WaterTooDeepForAttacks( pSoldier->sGridNo) )