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
+37 -34
View File
@@ -213,13 +213,16 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHa
if ( fFromUI )
{
INT16 sInteractiveGridNo;
// ATE: Check if we are targeting an interactive tile, and adjust gridno accordingly...
pIntNode = GetCurInteractiveTileGridNoAndStructure( &sGridNo, &pStructure );
pIntNode = GetCurInteractiveTileGridNoAndStructure( &sInteractiveGridNo, &pStructure );
if ( pIntNode != NULL && pTargetSoldier == pSoldier )
{
// Truncate target sioldier
// Truncate target soldier and update grid
pTargetSoldier = NULL;
sGridNo = sInteractiveGridNo;
}
}
}
@@ -502,7 +505,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHa
pSoldier->bDoAutofire += misfirePenalty;
sAPCost = CalcTotalAPsToAttack( pSoldier, sTargetGridNo, TRUE, 0 );
}
while(EnoughPoints( pSoldier, sAPCost, 0, FALSE ) && roll < ((pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft >= pSoldier->bDoAutofire)?chanceToMisfire:chanceToMisfireDry));
while(EnoughPoints( pSoldier, sAPCost, 0, FALSE ) && roll < ((pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft >= pSoldier->bDoAutofire)?chanceToMisfire:chanceToMisfireDry));
//note that we could misfire more bullets than we have rounds
//this represents the soldier running out of ammo and not noticing
//the max that can be lost this way is 1AP
@@ -510,17 +513,17 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHa
pSoldier->bDoAutofire -= misfirePenalty;
sAPCost = CalcTotalAPsToAttack( pSoldier, sTargetGridNo, TRUE, 0 );
if((__min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft) - startAuto) > 0 && pSoldier->bTeam == OUR_TEAM)
if((__min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft) - startAuto) > 0 && pSoldier->bTeam == OUR_TEAM)
{
// More than 1 round
if (__min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft) - startAuto > 1)
if (__min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft) - startAuto > 1)
{
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, gzLateLocalizedString[ 62 ], pSoldier->name, __min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft) - startAuto );
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, gzLateLocalizedString[ 62 ], pSoldier->name, __min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft) - startAuto );
}
// 1 round
else
{
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, gzLateLocalizedString[ 63 ], pSoldier->name, __min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft) - startAuto );
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, gzLateLocalizedString[ 63 ], pSoldier->name, __min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft) - startAuto );
}
}
@@ -1421,7 +1424,7 @@ void HandleSoldierDropBomb( SOLDIERTYPE *pSoldier, INT16 sGridNo )
StatChange( pSoldier, EXPLODEAMT, 25, FALSE );
pSoldier->inv[ HANDPOS ].bTrap = __min( 10, ( EffectiveExplosive( pSoldier ) / 20) + (EffectiveExpLevel( pSoldier ) / 3) );
pSoldier->inv[ HANDPOS ].ubBombOwner = pSoldier->ubID + 2;
pSoldier->inv[ HANDPOS ].ItemData.Trigger.ubBombOwner = pSoldier->ubID + 2;
// we now know there is something nasty here
gpWorldLevelData[ sGridNo ].uiFlags |= MAPELEMENT_PLAYER_MINE_PRESENT;
@@ -1753,7 +1756,7 @@ void SoldierGetItemFromWorld( SOLDIERTYPE *pSoldier, INT32 iItemIndex, INT16 sGr
if (Object.usItem == SWITCH)
{
// ask about activating the switch!
bTempFrequency = Object.bFrequency;
bTempFrequency = Object.ItemData.Trigger.BombTrigger.bFrequency;
gpTempSoldier = pSoldier;
DoMessageBox( MSG_BOX_BASIC_STYLE, TacticalStr[ ACTIVATE_SWITCH_PROMPT ] , GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, SwitchMessageBoxCallBack, NULL );
pItemPool = pItemPool->pNext;
@@ -1846,7 +1849,7 @@ void SoldierGetItemFromWorld( SOLDIERTYPE *pSoldier, INT32 iItemIndex, INT16 sGr
if (Object.usItem == SWITCH)
{
// handle switch
bTempFrequency = Object.bFrequency;
bTempFrequency = Object.ItemData.Trigger.BombTrigger.bFrequency;
gpTempSoldier = pSoldier;
DoMessageBox( MSG_BOX_BASIC_STYLE, TacticalStr[ ACTIVATE_SWITCH_PROMPT ], GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, SwitchMessageBoxCallBack, NULL );
}
@@ -2274,22 +2277,22 @@ OBJECTTYPE* InternalAddItemToPool( INT16 *psGridNo, OBJECTTYPE *pObject, INT8 bV
// and they are pressure-triggered unless there is a switch structure there
if (FindStructure( *psGridNo, STRUCTURE_SWITCH ) != NULL)
{
pObject->bDetonatorType = BOMB_SWITCH;
pObject->ItemData.Trigger.bDetonatorType = BOMB_SWITCH;
}
else
{
pObject->bDetonatorType = BOMB_PRESSURE;
pObject->ItemData.Trigger.bDetonatorType = BOMB_PRESSURE;
}
}
else
{
// else they are manually controlled
pObject->bDetonatorType = BOMB_SWITCH;
pObject->ItemData.Trigger.bDetonatorType = BOMB_SWITCH;
}
}
else if ( pObject->usItem == ACTION_ITEM )
{
switch( pObject->bActionValue )
switch( pObject->ItemData.Trigger.bActionValue )
{
case ACTION_ITEM_SMALL_PIT:
case ACTION_ITEM_LARGE_PIT:
@@ -4068,7 +4071,7 @@ void SoldierGiveItemFromAnimation( SOLDIERTYPE *pSoldier )
// are we giving money to an NPC, to whom we owe money?
if (pTSoldier->ubProfile != NO_PROFILE && gMercProfiles[pTSoldier->ubProfile].iBalance < 0)
{
gMercProfiles[pTSoldier->ubProfile].iBalance += TempObject.uiMoneyAmount;
gMercProfiles[pTSoldier->ubProfile].iBalance += TempObject.ItemData.Money.uiMoneyAmount;
if (gMercProfiles[pTSoldier->ubProfile].iBalance >= 0)
{
// don't let the player accumulate credit (?)
@@ -4276,7 +4279,7 @@ void BombMessageBoxCallBack( UINT8 ubExitValue )
// HACK IMMINENT!
// value of 1 is stored in maps for SIDE of bomb owner... when we want to use IDs!
// so we add 2 to all owner IDs passed through here and subtract 2 later
gpTempSoldier->inv[HANDPOS].ubBombOwner = gpTempSoldier->ubID + 2;
gpTempSoldier->inv[HANDPOS].ItemData.Trigger.ubBombOwner = gpTempSoldier->ubID + 2;
AddItemToPool( gsTempGridno, &(gpTempSoldier->inv[HANDPOS]), 1, gpTempSoldier->bLevel, WORLD_ITEM_ARMED_BOMB, 0 );
DeleteObj( &(gpTempSoldier->inv[HANDPOS]) );
}
@@ -4300,17 +4303,17 @@ BOOLEAN HandItemWorks( SOLDIERTYPE *pSoldier, INT8 bSlot )
if ( (Item[ pObj->usItem ].damageable ) && (!Item[pObj->usItem].mine ) && (Item[ pObj->usItem ].usItemClass != IC_MEDKIT) && !Item[pObj->usItem].gascan )
{
// if it's still usable, check whether it breaks
if ( pObj->bStatus[0] >= USABLE)
if ( pObj->ItemData.Generic.bStatus[0] >= USABLE)
{
// if a dice roll is greater than the item's status
if ( (Random(80) + 20) >= (UINT32) (pObj->bStatus[0] + 50) )
if ( (Random(80) + 20) >= (UINT32) (pObj->ItemData.Generic.bStatus[0] + 50) )
{
fItemJustBroke = TRUE;
fItemWorks = FALSE;
// item breaks, and becomes unusable... so its status is reduced
// to somewhere between 1 and the 1 less than USABLE
pObj->bStatus[0] = (INT8) ( 1 + Random( USABLE - 1 ) );
pObj->ItemData.Generic.bStatus[0] = (INT8) ( 1 + Random( USABLE - 1 ) );
}
}
else // it's already unusable
@@ -4333,8 +4336,8 @@ BOOLEAN HandItemWorks( SOLDIERTYPE *pSoldier, INT8 bSlot )
{
// are we using two guns at once?
if ( Item[ pSoldier->inv[SECONDHANDPOS].usItem ].usItemClass == IC_GUN &&
pSoldier->inv[SECONDHANDPOS].bGunStatus >= USABLE &&
pSoldier->inv[SECONDHANDPOS].ubGunShotsLeft > 0)
pSoldier->inv[SECONDHANDPOS].ItemData.Gun.bGunStatus >= USABLE &&
pSoldier->inv[SECONDHANDPOS].ItemData.Gun.ubGunShotsLeft > 0)
{
// check the second gun for breakage, and if IT breaks, return false
return( HandItemWorks( pSoldier, SECONDHANDPOS ) );
@@ -4508,9 +4511,9 @@ void BoobyTrapMessageBoxCallBack( UINT8 ubExitValue )
// NB owner grossness... bombs 'owned' by the enemy are stored with side value 1 in
// the map. So if we want to detect a bomb placed by the player, owner is > 1, and
// owner - 2 gives the ID of the character who planted it
if ( Object.ubBombOwner > 1 && ( (INT32)Object.ubBombOwner - 2 >= gTacticalStatus.Team[ OUR_TEAM ].bFirstID && Object.ubBombOwner - 2 <= gTacticalStatus.Team[ OUR_TEAM ].bLastID ) )
if ( Object.ItemData.Trigger.ubBombOwner > 1 && ( (INT32)Object.ItemData.Trigger.ubBombOwner - 2 >= gTacticalStatus.Team[ OUR_TEAM ].bFirstID && Object.ItemData.Trigger.ubBombOwner - 2 <= gTacticalStatus.Team[ OUR_TEAM ].bLastID ) )
{
if ( Object.ubBombOwner - 2 == gpBoobyTrapSoldier->ubID )
if ( Object.ItemData.Trigger.ubBombOwner - 2 == gpBoobyTrapSoldier->ubID )
{
// my own boobytrap!
iCheckResult = SkillCheck( gpBoobyTrapSoldier, DISARM_TRAP_CHECK, 40 );
@@ -4529,9 +4532,9 @@ void BoobyTrapMessageBoxCallBack( UINT8 ubExitValue )
if (iCheckResult >= 0)
{
if ( Object.ubBombOwner > 1 && ( (INT32)Object.ubBombOwner - 2 >= gTacticalStatus.Team[ OUR_TEAM ].bFirstID && Object.ubBombOwner - 2 <= gTacticalStatus.Team[ OUR_TEAM ].bLastID ) )
if ( Object.ItemData.Trigger.ubBombOwner > 1 && ( (INT32)Object.ItemData.Trigger.ubBombOwner - 2 >= gTacticalStatus.Team[ OUR_TEAM ].bFirstID && Object.ItemData.Trigger.ubBombOwner - 2 <= gTacticalStatus.Team[ OUR_TEAM ].bLastID ) )
{
if ( Object.ubBombOwner - 2 == gpBoobyTrapSoldier->ubID )
if ( Object.ItemData.Trigger.ubBombOwner - 2 == gpBoobyTrapSoldier->ubID )
{
// disarmed my own boobytrap!
StatChange( gpBoobyTrapSoldier, EXPLODEAMT, (UINT16) (2 * gbTrapDifficulty), FALSE );
@@ -4558,7 +4561,7 @@ void BoobyTrapMessageBoxCallBack( UINT8 ubExitValue )
// give the player a remote trigger instead
CreateItem( REMOTEBOMBTRIGGER, (INT8) (1 + Random( 9 )), &Object );
}
else if (Object.usItem == ACTION_ITEM && Object.bActionValue != ACTION_ITEM_BLOW_UP )
else if (Object.usItem == ACTION_ITEM && Object.ItemData.Trigger.bActionValue != ACTION_ITEM_BLOW_UP )
{
// give the player a detonator instead
CreateItem( DETONATOR, (INT8) (1 + Random( 9 )), &Object );
@@ -4566,7 +4569,7 @@ void BoobyTrapMessageBoxCallBack( UINT8 ubExitValue )
else
{
// switch action item to the real item type
CreateItem( Object.usBombItem, Object.bBombStatus, &Object );
CreateItem( Object.ItemData.Trigger.usBombItem, Object.ItemData.Trigger.bBombStatus, &Object );
}
// remove any blue flag graphic
@@ -4662,7 +4665,7 @@ void BoobyTrapInMapScreenMessageBoxCallBack( UINT8 ubExitValue )
// give the player a remote trigger instead
CreateItem( REMOTEBOMBTRIGGER, (INT8) (1 + Random( 9 )), &Object );
}
else if (Object.usItem == ACTION_ITEM && Object.bActionValue != ACTION_ITEM_BLOW_UP )
else if (Object.usItem == ACTION_ITEM && Object.ItemData.Trigger.bActionValue != ACTION_ITEM_BLOW_UP )
{
// give the player a detonator instead
CreateItem( DETONATOR, (INT8) (1 + Random( 9 )), &Object );
@@ -4670,7 +4673,7 @@ void BoobyTrapInMapScreenMessageBoxCallBack( UINT8 ubExitValue )
else
{
// switch action item to the real item type
CreateItem( Object.usBombItem, Object.bBombStatus, &Object );
CreateItem( Object.ItemData.Trigger.usBombItem, Object.ItemData.Trigger.bBombStatus, &Object );
}
}
else
@@ -4824,7 +4827,7 @@ BOOLEAN NearbyGroundSeemsWrong( SOLDIERTYPE * pSoldier, INT16 sGridNo, BOOLEAN f
if (gWorldBombs[uiWorldBombIndex].fExists && gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].sGridNo == sNextGridNo)
{
pObj = &( gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].o );
if ( pObj->bDetonatorType == BOMB_PRESSURE && !(pObj->fFlags & OBJECT_KNOWN_TO_BE_TRAPPED) && (!(pObj->fFlags & OBJECT_DISABLED_BOMB)) )
if ( pObj->ItemData.Trigger.bDetonatorType == BOMB_PRESSURE && !(pObj->fFlags & OBJECT_KNOWN_TO_BE_TRAPPED) && (!(pObj->fFlags & OBJECT_DISABLED_BOMB)) )
{
if ( fMining && pObj->bTrap <= 10 )
{
@@ -5047,18 +5050,18 @@ void CheckForPickedOwnership( void )
{
if ( gWorldItems[ pItemPool->iItemIndex ].o.usItem == OWNERSHIP )
{
if ( gWorldItems[ pItemPool->iItemIndex ].o.ubOwnerProfile != NO_PROFILE )
if ( gWorldItems[ pItemPool->iItemIndex ].o.ItemData.Owner.ubOwnerProfile != NO_PROFILE )
{
ubProfile = gWorldItems[ pItemPool->iItemIndex ].o.ubOwnerProfile;
ubProfile = gWorldItems[ pItemPool->iItemIndex ].o.ItemData.Owner.ubOwnerProfile;
pSoldier = FindSoldierByProfileID( ubProfile, FALSE );
if ( pSoldier )
{
TestPotentialOwner( pSoldier );
}
}
if ( gWorldItems[ pItemPool->iItemIndex ].o.ubOwnerCivGroup != NON_CIV_GROUP )
if ( gWorldItems[ pItemPool->iItemIndex ].o.ItemData.Owner.ubOwnerCivGroup != NON_CIV_GROUP )
{
ubCivGroup = gWorldItems[ pItemPool->iItemIndex ].o.ubOwnerCivGroup;
ubCivGroup = gWorldItems[ pItemPool->iItemIndex ].o.ItemData.Owner.ubOwnerCivGroup;
if ( ubCivGroup == HICKS_CIV_GROUP && CheckFact( FACT_HICKS_MARRIED_PLAYER_MERC, 0 ) )
{
// skip because hicks appeased