mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
- Code Improvement: it is now no longer necessary for the 'Full Sandbag' item to have a specific item number. The correct number will now be searched once per game.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5391 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -13949,3 +13949,19 @@ BOOLEAN HasItemFlag( UINT16 usItem, UINT32 aFlag )
|
||||
{
|
||||
return( (Item[usItem].usItemFlag & aFlag) != 0 );
|
||||
}
|
||||
|
||||
// Flugente: get first item number that has this flag. Use with caution, as we search in all items
|
||||
BOOLEAN GetFirstItemWithFlag( UINT16* pusItem, UINT32 aFlag )
|
||||
{
|
||||
register UINT16 i;
|
||||
for (i = 1; i < MAXITEMS; ++i)
|
||||
{
|
||||
if ( HasItemFlag(i, aFlag) )
|
||||
{
|
||||
(*pusItem) = i;
|
||||
return( TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
@@ -465,4 +465,7 @@ void CheckBombSpecifics( OBJECTTYPE * pObj, INT8* detonatortype, INT8* setting,
|
||||
// Flugente: check for specific flags
|
||||
BOOLEAN HasItemFlag( UINT16 usItem, UINT32 aFlag );
|
||||
|
||||
// Flugente: get first item number that has this flag. Use with caution, as we search in all items
|
||||
BOOLEAN GetFirstItemWithFlag( UINT16* pusItem, UINT32 aFlag );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -14424,6 +14424,8 @@ extern UINT8 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSecto
|
||||
|
||||
void SOLDIERTYPE::EVENT_SoldierBuildStructure( INT32 sGridNo, UINT8 ubDirection )
|
||||
{
|
||||
// a static variable that is the item number of sandbags. Hardcoding item numbers is bad, that's why we will search for it.
|
||||
static UINT16 fullsandbagnr = 1541;
|
||||
BOOLEAN fSuccess = FALSE;
|
||||
|
||||
// if specified by the ini, building/disassembling stuff is disabled while enemies are around
|
||||
@@ -14483,9 +14485,8 @@ void SOLDIERTYPE::EVENT_SoldierBuildStructure( INT32 sGridNo, UINT8 ubDirection
|
||||
|
||||
if ( pShovelObj && pShovelObj->exists() && HasItemFlag(this->inv[ SECONDHANDPOS ].usItem, (SHOVEL)) )
|
||||
{
|
||||
// test: does there an item that is a filled sandbag exist? (xmls might have changed)
|
||||
UINT16 fullsandbagnr = 1541;
|
||||
if ( HasItemFlag(fullsandbagnr, FULL_SANDBAG) )
|
||||
// eventually search for the number of a sandbag item
|
||||
if ( HasItemFlag(fullsandbagnr, FULL_SANDBAG) || GetFirstItemWithFlag(&fullsandbagnr, FULL_SANDBAG) )
|
||||
{
|
||||
// Erase 'material' item from our hand - we 'used' it to build the structure
|
||||
INT8 bObjSlot = HANDPOS;
|
||||
@@ -14502,27 +14503,6 @@ void SOLDIERTYPE::EVENT_SoldierBuildStructure( INT32 sGridNo, UINT8 ubDirection
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14531,9 +14511,8 @@ void SOLDIERTYPE::EVENT_SoldierBuildStructure( INT32 sGridNo, UINT8 ubDirection
|
||||
// Build the thing
|
||||
if ( RemoveFortification( sGridNo ) )
|
||||
{
|
||||
// test: does there an item that is a filled sandbag exist? (xmls might have changed)
|
||||
UINT16 fullsandbagnr = 1541;
|
||||
if ( HasItemFlag(fullsandbagnr, FULL_SANDBAG) )
|
||||
// eventually search for the number of a sandbag item
|
||||
if ( HasItemFlag(fullsandbagnr, FULL_SANDBAG) || GetFirstItemWithFlag(&fullsandbagnr, FULL_SANDBAG) )
|
||||
{
|
||||
// Erase 'material' item from our hand - we 'used' it to build the structure
|
||||
INT8 bObjSlot = HANDPOS;
|
||||
@@ -14551,28 +14530,6 @@ void SOLDIERTYPE::EVENT_SoldierBuildStructure( INT32 sGridNo, UINT8 ubDirection
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user