Fix for AI seeking climb point in toxic gas

Fix for civilians trying to climb the roof to seek noise
Fix for punching and stabbing
Transparent change: Gave names to anonymous structs in OBJECTTYPE


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1225 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Overhaul
2007-08-18 19:03:20 +00:00
parent 29b883f59d
commit fccef1faea
60 changed files with 921 additions and 887 deletions
+9 -9
View File
@@ -764,7 +764,7 @@ BOOLEAN DoesCharacterHaveAnyItemsToRepair( SOLDIERTYPE *pSoldier, INT8 bHighestP
for( ubObjectInPocketCounter = 0; ubObjectInPocketCounter < ubItemsInPocket; ubObjectInPocketCounter++ )
{
// jammed gun?
if ( ( Item[ pSoldier -> inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pSoldier -> inv[ bPocket ].bGunAmmoStatus < 0 ) )
if ( ( Item[ pSoldier -> inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pSoldier -> inv[ bPocket ].ItemData.Gun.bGunAmmoStatus < 0 ) )
{
return( TRUE );
}
@@ -782,7 +782,7 @@ BOOLEAN DoesCharacterHaveAnyItemsToRepair( SOLDIERTYPE *pSoldier, INT8 bHighestP
for( ubObjectInPocketCounter = 0; ubObjectInPocketCounter < ubItemsInPocket; ubObjectInPocketCounter++ )
{
// if it's repairable and NEEDS repairing
if ( IsItemRepairable( pObj->usItem, pObj->bStatus[ubObjectInPocketCounter] ) )
if ( IsItemRepairable( pObj->usItem, pObj->ItemData.Generic.bStatus[ubObjectInPocketCounter] ) )
{
return( TRUE );
}
@@ -818,7 +818,7 @@ BOOLEAN DoesCharacterHaveAnyItemsToRepair( SOLDIERTYPE *pSoldier, INT8 bHighestP
for ( bPocket = HANDPOS; bPocket <= SMALLPOCK8POS; bPocket++ )
{
// the object a weapon? and jammed?
if ( ( Item[ pOtherSoldier->inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pOtherSoldier->inv[ bPocket ].bGunAmmoStatus < 0 ) )
if ( ( Item[ pOtherSoldier->inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pOtherSoldier->inv[ bPocket ].ItemData.Gun.bGunAmmoStatus < 0 ) )
{
return( TRUE );
}
@@ -2981,7 +2981,7 @@ INT8 FindRepairableItemOnOtherSoldier( SOLDIERTYPE * pSoldier, UINT8 ubPassType
pObj = &( pSoldier->inv[ bSlotToCheck ] );
for ( bLoop2 = 0; bLoop2 < pSoldier->inv[ bSlotToCheck ].ubNumberOfObjects; bLoop2++ )
{
if ( IsItemRepairable( pObj->usItem, pObj->bStatus[bLoop2] ) )
if ( IsItemRepairable( pObj->usItem, pObj->ItemData.Generic.bStatus[bLoop2] ) )
{
return( bSlotToCheck );
}
@@ -3074,16 +3074,16 @@ BOOLEAN RepairObject( SOLDIERTYPE * pSoldier, SOLDIERTYPE * pOwner, OBJECTTYPE *
for ( ubLoop = 0; ubLoop < ubItemsInPocket; ubLoop++ )
{
// if it's repairable and NEEDS repairing
if ( IsItemRepairable( pObj->usItem, pObj->bStatus[ubLoop] ) )
if ( IsItemRepairable( pObj->usItem, pObj->ItemData.Generic.bStatus[ubLoop] ) )
{
// repairable, try to repair it
//void DoActualRepair( SOLDIERTYPE * pSoldier, UINT16 usItem, INT8 * pbStatus, UINT8 * pubRepairPtsLeft )
DoActualRepair( pSoldier, pObj->usItem, &(pObj->bStatus[ ubLoop ]), pubRepairPtsLeft );
DoActualRepair( pSoldier, pObj->usItem, &(pObj->ItemData.Generic.bStatus[ ubLoop ]), pubRepairPtsLeft );
fSomethingWasRepaired = TRUE;
if ( pObj->bStatus[ ubLoop ] == 100 )
if ( pObj->ItemData.Generic.bStatus[ ubLoop ] == 100 )
{
// report it as fixed
if ( pSoldier == pOwner )
@@ -11545,13 +11545,13 @@ BOOLEAN UnjamGunsOnSoldier( SOLDIERTYPE *pOwnerSoldier, SOLDIERTYPE *pRepairSold
for (bPocket = HANDPOS; bPocket <= SMALLPOCK8POS; bPocket++)
{
// the object a weapon? and jammed?
if ( ( Item[ pOwnerSoldier->inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pOwnerSoldier->inv[ bPocket ].bGunAmmoStatus < 0 ) )
if ( ( Item[ pOwnerSoldier->inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pOwnerSoldier->inv[ bPocket ].ItemData.Gun.bGunAmmoStatus < 0 ) )
{
if ( *pubRepairPtsLeft >= gGameExternalOptions.ubRepairCostPerJam )
{
*pubRepairPtsLeft -= gGameExternalOptions.ubRepairCostPerJam;
pOwnerSoldier->inv [ bPocket ].bGunAmmoStatus *= -1;
pOwnerSoldier->inv [ bPocket ].ItemData.Gun.bGunAmmoStatus *= -1;
// MECHANICAL/DEXTERITY GAIN: Unjammed a gun
StatChange( pRepairSoldier, MECHANAMT, 5, FALSE );
+5 -5
View File
@@ -3931,15 +3931,15 @@ BOOLEAN FireAShot( SOLDIERCELL *pAttacker )
PlayAutoResolveSample( Weapon[ pItem->usItem ].sSound, RATE_11025, 50, 1, MIDDLEPAN );
return TRUE;
}
if( !pItem->ubGunShotsLeft )
if( !pItem->ItemData.Gun.ubGunShotsLeft )
{
AutoReload( pSoldier );
if ( pItem->ubGunShotsLeft && Weapon[ pItem->usItem ].sLocknLoadSound )
if ( pItem->ItemData.Gun.ubGunShotsLeft && Weapon[ pItem->usItem ].sLocknLoadSound )
{
PlayAutoResolveSample( Weapon[ pItem->usItem ].sLocknLoadSound, RATE_11025, 50, 1, MIDDLEPAN );
}
}
if( pItem->ubGunShotsLeft )
if( pItem->ItemData.Gun.ubGunShotsLeft )
{
PlayAutoResolveSample( Weapon[ pItem->usItem ].sSound, RATE_11025, 50, 1, MIDDLEPAN );
if( pAttacker->uiFlags & CELL_MERC )
@@ -3949,7 +3949,7 @@ BOOLEAN FireAShot( SOLDIERCELL *pAttacker )
StatChange( pAttacker->pSoldier, MARKAMT, 3, FALSE );
}
pItem->ubGunShotsLeft--;
pItem->ItemData.Gun.ubGunShotsLeft--;
return TRUE;
}
}
@@ -3986,7 +3986,7 @@ BOOLEAN TargetHasLoadedGun( SOLDIERTYPE *pSoldier )
{
return TRUE;
}
if( pItem->ubGunShotsLeft )
if( pItem->ItemData.Gun.ubGunShotsLeft )
{
return TRUE;
}
@@ -1516,7 +1516,7 @@ BOOLEAN GetObjFromInventoryStashSlot( OBJECTTYPE *pInventorySlot, OBJECTTYPE *pI
pItemPtr->usItem = pInventorySlot->usItem;
// find first unempty slot
pItemPtr->bStatus[0] = pInventorySlot->bStatus[0];
pItemPtr->ItemData.Generic.bStatus[0] = pInventorySlot->ItemData.Generic.bStatus[0];
pItemPtr->ubNumberOfObjects = 1;
pItemPtr->ubWeight = CalculateObjectWeight( pItemPtr );
RemoveObjFrom( pInventorySlot, 0 );
@@ -1573,7 +1573,7 @@ BOOLEAN PlaceObjectInInventoryStash( OBJECTTYPE *pInventorySlot, OBJECTTYPE *pIt
// in the InSlot copy, zero out all the objects we didn't drop
for (ubLoop = ubNumberToDrop; ubLoop < pItemPtr->ubNumberOfObjects; ubLoop++)
{
pInventorySlot->bStatus[ubLoop] = 0;
pInventorySlot->ItemData.Generic.bStatus[ubLoop] = 0;
}
}
pInventorySlot->ubNumberOfObjects = ubNumberToDrop;
@@ -1594,8 +1594,8 @@ BOOLEAN PlaceObjectInInventoryStash( OBJECTTYPE *pInventorySlot, OBJECTTYPE *pIt
{
// always allow money to be combined!
// average out the status values using a weighted average...
pInventorySlot->bStatus[0] = (INT8) ( ( (UINT32)pInventorySlot->bMoneyStatus * pInventorySlot->uiMoneyAmount + (UINT32)pItemPtr->bMoneyStatus * pItemPtr->uiMoneyAmount )/ (pInventorySlot->uiMoneyAmount + pItemPtr->uiMoneyAmount) );
pInventorySlot->uiMoneyAmount += pItemPtr->uiMoneyAmount;
pInventorySlot->ItemData.Generic.bStatus[0] = (INT8) ( ( (UINT32)pInventorySlot->ItemData.Money.bMoneyStatus * pInventorySlot->ItemData.Money.uiMoneyAmount + (UINT32)pItemPtr->ItemData.Money.bMoneyStatus * pItemPtr->ItemData.Money.uiMoneyAmount )/ (pInventorySlot->ItemData.Money.uiMoneyAmount + pItemPtr->ItemData.Money.uiMoneyAmount) );
pInventorySlot->ItemData.Money.uiMoneyAmount += pItemPtr->ItemData.Money.uiMoneyAmount;
DeleteObj( pItemPtr );
}
@@ -1654,7 +1654,7 @@ BOOLEAN AutoPlaceObjectInInventoryStash( OBJECTTYPE *pItemPtr )
// in the InSlot copy, zero out all the objects we didn't drop
for (ubLoop = ubNumberToDrop; ubLoop < pItemPtr->ubNumberOfObjects; ubLoop++)
{
pInventorySlot->bStatus[ubLoop] = 0;
pInventorySlot->ItemData.Generic.bStatus[ubLoop] = 0;
}
}
pInventorySlot->ubNumberOfObjects = ubNumberToDrop;
@@ -2238,8 +2238,8 @@ INT32 MapScreenSectorInventoryCompare( const void *pNum1, const void *pNum2)
usItem1Index = pFirst->o.usItem;
usItem2Index = pSecond->o.usItem;
ubItem1Quality = pFirst->o.bStatus[ 0 ];
ubItem2Quality = pSecond->o.bStatus[ 0 ];
ubItem1Quality = pFirst->o.ItemData.Generic.bStatus[ 0 ];
ubItem2Quality = pSecond->o.ItemData.Generic.bStatus[ 0 ];
return( CompareItemsForSorting( usItem1Index, usItem2Index, ubItem1Quality, ubItem2Quality ) );
}
@@ -2282,6 +2282,10 @@ void DeleteAllItemsInInventoryPool()
ClearUpTempUnSeenList( );
SaveSeenAndUnseenItems();
iCurrentInventoryPoolPage = 0;
iLastInventoryPoolPage = 0;
DestroyStash();
BuildStashForSelectedSector( sSelMapX, sSelMapY, iCurrentMapSectorZ);
}
@@ -2315,7 +2319,7 @@ INT32 SellItem( OBJECTTYPE& object )
UINT8 magSize = Magazine[ Item[ usItemType ].ubClassIndex ].ubMagSize;
for (INT8 bLoop = 0; bLoop < object.ubNumberOfObjects; bLoop++)
{
iPrice += (INT32)( itemPrice * (float) object.ubShotsLeft[bLoop] / magSize );
iPrice += (INT32)( itemPrice * (float) object.ItemData.Ammo.ubShotsLeft[bLoop] / magSize );
}
}
else
@@ -2323,7 +2327,7 @@ INT32 SellItem( OBJECTTYPE& object )
//we are selling a gun or something - it could be stacked or single, and each one could have attachments
for (INT8 bLoop = 0; bLoop < object.ubNumberOfObjects; bLoop++)
{
iPrice += ( itemPrice * object.bStatus[bLoop] / 100 );
iPrice += ( itemPrice * object.ItemData.Generic.bStatus[bLoop] / 100 );
for (INT8 numAttachments = 0; numAttachments < MAX_ATTACHMENTS; numAttachments++)
{
+4 -1
View File
@@ -1218,7 +1218,10 @@ void AddPossiblePendingEnemiesToBattle()
// Assume we added one since there are supposedly more available and room for them
ubSlots--;
}
return;
// It's probable that the "pending enemies" flag isn't working right. So we'll go ahead and continue into
// the group insertion code from here.
//return;
}
if( pSector->ubNumElites + pSector->ubNumTroops + pSector->ubNumAdmins )
+10 -10
View File
@@ -189,7 +189,7 @@ void BobbyRayPurchaseEventCallback( UINT8 ubOrderID )
{
// Empty out the bullets put in by CreateItem(). We now sell all guns empty of bullets. This is done for BobbyR
// simply to be consistent with the dealers in Arulco, who must sell guns empty to prevent ammo cheats by players.
Object.ubGunShotsLeft = 0;
Object.ItemData.Gun.ubGunShotsLeft = 0;
}
ubItemsDelivered = 0;
@@ -220,11 +220,11 @@ void BobbyRayPurchaseEventCallback( UINT8 ubOrderID )
if (usStandardMapPos == LOST_SHIPMENT_GRIDNO)
{
// damage the item a random amount!
Object.bStatus[0] = (INT8) ( ( (70 + Random( 11 )) * (INT32) Object.bStatus[0] ) / 100 );
Object.ItemData.Generic.bStatus[0] = (INT8) ( ( (70 + Random( 11 )) * (INT32) Object.ItemData.Generic.bStatus[0] ) / 100 );
// make damn sure it can't hit 0
if (Object.bStatus[0] == 0)
if (Object.ItemData.Generic.bStatus[0] == 0)
{
Object.bStatus[0] = 1;
Object.ItemData.Generic.bStatus[0] = 1;
}
AddItemToPool( usMapPos, &Object, -1, 0, 0, 0 );
}
@@ -254,11 +254,11 @@ void BobbyRayPurchaseEventCallback( UINT8 ubOrderID )
if (usStandardMapPos == LOST_SHIPMENT_GRIDNO)
{
// damage the item a random amount!
Object.bStatus[0] = (INT8) ( ( (70 + Random( 11 )) * (INT32) Object.bStatus[0] ) / 100 );
Object.ItemData.Generic.bStatus[0] = (INT8) ( ( (70 + Random( 11 )) * (INT32) Object.ItemData.Generic.bStatus[0] ) / 100 );
// make damn sure it can't hit 0
if (Object.bStatus[0] == 0)
if (Object.ItemData.Generic.bStatus[0] == 0)
{
Object.bStatus[0] = 1;
Object.ItemData.Generic.bStatus[0] = 1;
}
memcpy( &pObject[ uiCount ], &Object, sizeof( OBJECTTYPE ) );
uiCount++;
@@ -559,7 +559,7 @@ void CheckForKingpinsMoneyMissing( BOOLEAN fFirstCheck )
// loop through all items, look for ownership
if ( gWorldItems[ uiLoop ].fExists && gWorldItems[ uiLoop ].o.usItem == MONEY )
{
uiTotalCash += gWorldItems[uiLoop].o.uiMoneyAmount;
uiTotalCash += gWorldItems[uiLoop].o.ItemData.Money.uiMoneyAmount;
}
}
@@ -1043,14 +1043,14 @@ void CheckForMissingHospitalSupplies( void )
for ( uiLoop = 0; uiLoop < guiNumWorldItems; uiLoop++ )
{
// loop through all items, look for ownership
if ( gWorldItems[ uiLoop ].fExists && gWorldItems[ uiLoop ].o.usItem == OWNERSHIP && gWorldItems[ uiLoop ].o.ubOwnerCivGroup == DOCTORS_CIV_GROUP )
if ( gWorldItems[ uiLoop ].fExists && gWorldItems[ uiLoop ].o.usItem == OWNERSHIP && gWorldItems[ uiLoop ].o.ItemData.Owner.ubOwnerCivGroup == DOCTORS_CIV_GROUP )
{
GetItemPool( gWorldItems[ uiLoop ].sGridNo, &pItemPool, 0 ) ;
while( pItemPool )
{
pObj = &( gWorldItems[ pItemPool->iItemIndex ].o );
if ( pObj->bStatus[ 0 ] > 60 )
if ( pObj->ItemData.Generic.bStatus[ 0 ] > 60 )
{
if ( Item[pObj->usItem].firstaidkit || Item[pObj->usItem].medicalkit || pObj->usItem == REGEN_BOOSTER || pObj->usItem == ADRENALINE_BOOSTER )
{
+4 -4
View File
@@ -4543,17 +4543,17 @@ void AddFuelToVehicle( SOLDIERTYPE *pSoldier, SOLDIERTYPE *pVehicle )
{ //Message for vehicle full?
return;
}
if( pItem->bStatus )
if( pItem->ItemData.Generic.bStatus )
{ //Fill 'er up.
sFuelNeeded = 10000 - pVehicle->sBreathRed;
sFuelAvailable = pItem->bStatus[0] * 50;
sFuelAvailable = pItem->ItemData.Generic.bStatus[0] * 50;
sFuelAdded = min( sFuelNeeded, sFuelAvailable );
//Add to vehicle
pVehicle->sBreathRed += sFuelAdded;
pVehicle->bBreath = (INT8)(pVehicle->sBreathRed / 100);
//Subtract from item
pItem->bStatus[0] = (INT8)(pItem->bStatus[0] - sFuelAdded / 50);
if( !pItem->bStatus[0] )
pItem->ItemData.Generic.bStatus[0] = (INT8)(pItem->ItemData.Generic.bStatus[0] - sFuelAdded / 50);
if( !pItem->ItemData.Generic.bStatus[0] )
{ //Gas can is empty, so toast the item.
DeleteObj( pItem );
}
+1 -1
View File
@@ -5230,7 +5230,7 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
SOLDIERTYPE *pSoldier = MercPtrs[ gCharactersList[ bSelectedInfoChar ].usSolID ];
if ( pSoldier->inv[ HANDPOS ].usItem != 0 )
{
pSoldier->inv[ HANDPOS ].bStatus[ 0 ] = 2;
pSoldier->inv[ HANDPOS ].ItemData.Generic.bStatus[ 0 ] = 2;
}
}
}
+12 -1
View File
@@ -1741,6 +1741,11 @@ BOOLEAN SetCurrentWorldSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ )
PrepareEnemyForSectorBattle();
}
for (int i=0; i<TOTAL_SOLDIERS; i++)
{
Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE);
}
if( gubNumCreaturesAttackingTown && !gbWorldSectorZ &&
gubSectorIDOfCreatureAttack == SECTOR( gWorldSectorX, gWorldSectorY ) )
{
@@ -1755,7 +1760,7 @@ BOOLEAN SetCurrentWorldSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ )
// Check for helicopter being on the ground in this sector...
HandleHelicopterOnGroundGraphic( );
// 0verhaul: Okay, it is apparent that the enemies are not reset incorrectly. So I will now try to add symmetry
// 0verhaul: Okay, it is apparent that the enemies are not reset correctly. So I will now try to add symmetry
// between enemy placement and militia placement. The enemies do have one advantage here, though: If a sector
// is in enemy hands, then their sector is not actually loaded. At least not normally. Perhaps it would be useful
// to lose a battle with one group of mercs, then bring in another group without changing to another sector to see
@@ -1766,6 +1771,12 @@ BOOLEAN SetCurrentWorldSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ )
// except for the case of training new militia. But that case can be handled each time militia training finishes.
// ResetMilitia();
AllTeamsLookForAll( TRUE );
for (int i=0; i<TOTAL_SOLDIERS; i++)
{
Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE);
}
return( TRUE );
}