From a184f7675378251a68c09fe6d30b7e1d4585492e Mon Sep 17 00:00:00 2001 From: Shadooow Date: Mon, 28 Feb 2022 22:23:33 +0000 Subject: [PATCH] Fix for grenades being put into inventory instead back into hand if the soldier is stopped from throwing it in middle of animation by game (interrupt/spotting another enemy). git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9311 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Soldier Control.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index be7e1800..4d7ffc5d 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -14183,15 +14183,26 @@ void SOLDIERTYPE::HaultSoldierFromSighting( BOOLEAN fFromSightingEnemy ) // OK, check if we were going to throw something, and give it back if so! if ( this->pTempObject != NULL && fFromSightingEnemy ) { - // Place it back into inv.... - AutoPlaceObject( this, this->pTempObject, FALSE ); + if ( this->pThrowParams->ubActionCode == THROW_ARM_ITEM ) + { + if (!this->inv[HANDPOS].exists()) + { + // put the one-handed weapon in the guy's hand... + if (!PlaceObject(this, HANDPOS, this->pTempObject)) + { + AutoPlaceObject(this, this->pTempObject, FALSE); + } + } + //AXP 25.03.2007: Not needed anymore, grenade costs are only deducted on throwing the object + //AXP 24.03.2007: Give APs back if we wanted to throw grenade, but interrupt/spotting occured + //DeductPoints( this, -MinAPsToAttack( this, this->sTargetGridNo, FALSE ), 0 ); + } + else + { + // Place it back into inv.... + AutoPlaceObject(this, this->pTempObject, FALSE); + } - //AXP 25.03.2007: Not needed anymore, grenade costs are only deducted on throwing the object - //AXP 24.03.2007: Give APs back if we wanted to throw grenade, but interrupt/spotting occured - //if ( this->pThrowParams->ubActionCode == THROW_ARM_ITEM ) - //{ - // DeductPoints( this, -MinAPsToAttack( this, this->sTargetGridNo, FALSE ), 0 ); - //} OBJECTTYPE::DeleteMe( &this->pTempObject ); this->usPendingAnimation = NO_PENDING_ANIMATION;