Improved code to spawn item and it's attachments when disarming bomb.

Update sight after item transformation.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8909 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2020-10-23 13:15:31 +00:00
parent 59f91fc065
commit e738e4424d
2 changed files with 21 additions and 23 deletions
+18 -23
View File
@@ -6172,38 +6172,33 @@ void BoobyTrapMessageBoxCallBack( UINT8 ubExitValue )
}
else
{
// if this is a tripwire, it might have an attached gun, which we also have to spawn
if ( Item[gTempObject.usItem].tripwire )
OBJECTTYPE TempObject;
CreateItem(gTempObject[0]->data.misc.usBombItem, gTempObject[0]->data.misc.bBombStatus, &TempObject);
// also spawn attached guns/explosives
if (gTempObject.usItem != ACTION_ITEM && (Item[gTempObject.usItem].tripwire || Item[gTempObject.usItem].usItemClass & IC_EXPLOSV))
{
// search for attached guns
OBJECTTYPE* pAttGun = NULL;
// search for attached items
OBJECTTYPE* pAttItem = NULL;
// check all attachments
attachmentList::iterator iterend = gTempObject[0]->attachments.end( );
for ( attachmentList::iterator iter = gTempObject[0]->attachments.begin( ); iter != iterend; ++iter )
attachmentList::iterator iterend = gTempObject[0]->attachments.end();
for (attachmentList::iterator iter = gTempObject[0]->attachments.begin(); iter != iterend; ++iter)
{
if ( iter->exists( ) && Item[iter->usItem].usItemClass == IC_GUN )
//if ( iter->exists( ) && Item[iter->usItem].usItemClass == IC_GUN )
if (iter->exists())
{
pAttGun = &(*iter);
pAttItem = &(*iter);
// add this gun to the floor
AddItemToPool( gsBoobyTrapGridNo, pAttGun, 1, gbBoobyTrapLevel, 0, -1 );
if (Item[iter->usItem].usItemClass == IC_GUN)
AddItemToPool(gsBoobyTrapGridNo, pAttItem, 1, gbBoobyTrapLevel, 0, -1);
else
TempObject.AttachObject(NULL, pAttItem, FALSE);
}
}
}
// switch action item to the real item type
// sevenfm: added check to only switch action items and not regular explosives
// this allows to keep all attachments
if( gTempObject.usItem == ACTION_ITEM || !gGameExternalOptions.bAllowExplosiveAttachments )
{
CreateItem( gTempObject[0]->data.misc.usBombItem, gTempObject[0]->data.misc.bBombStatus, &gTempObject );
}
else
{
gTempObject.fFlags &= ~(OBJECT_ARMED_BOMB);
gTempObject[0]->data.misc.bDetonatorType = 0;
}
gTempObject = TempObject;
if (is_networked && is_client)
{
@@ -6211,7 +6206,7 @@ void BoobyTrapMessageBoxCallBack( UINT8 ubExitValue )
// attach whatever trigger the bomb originally had
if (gWorldItems[ gpBoobyTrapItemPool->iItemIndex ].object[0]->data.misc.bDetonatorType == BOMB_REMOTE)
{
// attack a remote deonator, but they will need a trigger to use it :)
// attack a remote detonator, but they will need a trigger to use it :)
CreateItem( REMDETONATOR, gTempObject[0]->data.misc.bBombStatus, &TempAttachment );
}
else
+3
View File
@@ -14992,6 +14992,9 @@ BOOLEAN OBJECTTYPE::TransformObject( SOLDIERTYPE * pSoldier, UINT8 ubStatusIndex
// Flugente: we have to recheck our flashlights
pSoldier->HandleFlashLights();
// sevenfm: handle sight change
HandleSight(pSoldier, SIGHT_LOOK | SIGHT_INTERRUPT);
// Signal a successful transformation.
return TRUE;
}