- removed compile warnings

- Fix: sometimes, capturing the last enemy did not end combat as it should
- code change: POW are no longer considered visible opponents. This avoids the error of incorrect sight counters (a bit similar to dying enemies)

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5752 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2012-12-29 17:24:16 +00:00
parent 4eccdec2ee
commit 3e859f91a8
5 changed files with 34 additions and 30 deletions
+6 -2
View File
@@ -6765,10 +6765,11 @@ void RemoveCapturedEnemiesFromSectorInfo( INT16 sMapX, INT16 sMapY, INT8 bMapZ )
// Kill those not already dead.,...
if ( pTeamSoldier->bActive && pTeamSoldier->bInSector && pTeamSoldier->bTeam == ENEMY_TEAM )
{
// For sure for flag thet they are dead is not set
// Only pows that are not dead yet
if ( ( pTeamSoldier->bSoldierFlagMask & SOLDIER_POW ) && !( pTeamSoldier->flags.uiStatusFlags & SOLDIER_DEAD ) )
{
if ( pTeamSoldier->stats.bLife > OKLIFE && pTeamSoldier->stats.bLife != 0 )
// if we arrive here and the guy has lifepoints < OKLIFE, something is very odd... better take him prisoner and remove him anyway
//if ( pTeamSoldier->stats.bLife > OKLIFE && pTeamSoldier->stats.bLife != 0 )
{
switch ( pTeamSoldier->ubSoldierClass )
{
@@ -10109,6 +10110,9 @@ void PrisonerSurrenderMessageBoxCallBack( UINT8 ubExitValue )
if( pSoldier->stats.bLife >= OKLIFE )
{
pSoldier->bSoldierFlagMask |= SOLDIER_POW;
// Remove as target
RemoveManAsTarget( pSoldier );
}
}
}
+6
View File
@@ -16326,6 +16326,9 @@ void SOLDIERTYPE::EVENT_SoldierHandcuffPerson( INT32 sGridNo, UINT8 ubDirection
// arrest this guy
pSoldier->bSoldierFlagMask |= SOLDIER_POW;
// Remove as target
RemoveManAsTarget( pSoldier );
// move the items in his hands to the floor and move our handcuff into his hands
if ( pSoldier->inv[ HANDPOS ].exists() == true && !( pSoldier->inv[ HANDPOS ].fFlags & OBJECT_UNDROPPABLE ))
{
@@ -16381,6 +16384,9 @@ void SOLDIERTYPE::EVENT_SoldierHandcuffPerson( INT32 sGridNo, UINT8 ubDirection
StatChange( this, EXPERAMT, 2, TRUE );
DeductPoints( this, GetAPsToHandcuff( this, sGridNo ), 0, AFTERACTION_INTERRUPT );
// this might have been the last guy...
CheckForEndOfBattle( FALSE );
}
else
{
-3
View File
@@ -414,9 +414,6 @@ extern CLOTHES_STRUCT Clothes[CLOTHES_MAX];
// but they can't attack empty vehicles!!
#define CONSIDERED_NEUTRAL( me, them ) ( (them->aiData.bNeutral || them->bSoldierFlagMask & (SOLDIER_COVERT_CIV|SOLDIER_COVERT_SOLDIER|SOLDIER_POW)) && ( me->bTeam != CREATURE_TEAM || (them->flags.uiStatusFlags & SOLDIER_VEHICLE) ) )
// Flugente: this version still counts POWs as enemies. This allows correct refreshing of the enemy count whn taking prisoners and then moving away
#define CONSIDERED_NEUTRAL_NOT_POW( me, them ) ( (them->aiData.bNeutral || them->bSoldierFlagMask & (SOLDIER_COVERT_CIV|SOLDIER_COVERT_SOLDIER)) && ( me->bTeam != CREATURE_TEAM || (them->flags.uiStatusFlags & SOLDIER_VEHICLE) ) )
typedef struct
{
UINT8 ubKeyID;
+1 -1
View File
@@ -1773,7 +1773,7 @@ void HandleManNoLongerSeen( SOLDIERTYPE * pSoldier, SOLDIERTYPE * pOpponent, INT
{
// if neither side is neutral AND
// if this soldier is an opponent (fights for different side)
if (pSoldier->bActive && pOpponent->bActive && !CONSIDERED_NEUTRAL_NOT_POW( pOpponent, pSoldier ) && !CONSIDERED_NEUTRAL_NOT_POW( pSoldier, pOpponent ) && (pSoldier->bSide != pOpponent->bSide) && pSoldier->RecognizeAsCombatant(pOpponent->ubID) )
if (pSoldier->bActive && pOpponent->bActive && !CONSIDERED_NEUTRAL( pOpponent, pSoldier ) && !CONSIDERED_NEUTRAL( pSoldier, pOpponent ) && (pSoldier->bSide != pOpponent->bSide) && pSoldier->RecognizeAsCombatant(pOpponent->ubID) )
{
RemoveOneOpponent(pSoldier);
}
+21 -24
View File
@@ -5351,15 +5351,15 @@ INT16 ubMinAPCost;
// if yes, and we are facing it, jump
// if no, go on, nothing to see here
// determine direction of our target
INT8 targetdirection = GetDirectionToGridNoFromGridNo(pSoldier->sGridNo, sClosestOpponent);
UINT8 targetdirection = GetDirectionToGridNoFromGridNo(pSoldier->sGridNo, sClosestOpponent);
// determine if there is a jumpable window here, in the direction of our target
// store old direction for this check
INT tmpdirection = pSoldier->ubDirection;
UINT8 tmpdirection = pSoldier->ubDirection;
pSoldier->ubDirection = targetdirection;
INT8 windowdirection = DIRECTION_IRRELEVANT;
if ( FindWindowJumpDirection(pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &windowdirection) && targetdirection == windowdirection )
if ( FindWindowJumpDirection(pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &windowdirection) && targetdirection == (UINT8)windowdirection )
{
pSoldier->ubDirection = tmpdirection;
@@ -5389,31 +5389,28 @@ INT16 ubMinAPCost;
// The situation mentioned above happens...
else if ( (targetbLevel != pSoldier->pathing.bLevel) && SameBuilding( pSoldier->sGridNo, targetGridNo ) )
{
if ( 1 )//gGameExternalOptions.fZombieCanClimb )
if (!TileIsOutOfBounds(targetGridNo) )
{
if (!TileIsOutOfBounds(targetGridNo) )
// need to climb AND have enough APs to get there this turn
BOOLEAN fUp = TRUE;
if (pSoldier->pathing.bLevel > 0 )
fUp = FALSE;
if ( pSoldier->bActionPoints > GetAPsToClimbRoof ( pSoldier, fUp ) )
{
// need to climb AND have enough APs to get there this turn
BOOLEAN fUp = TRUE;
if (pSoldier->pathing.bLevel > 0 )
fUp = FALSE;
pSoldier->aiData.usActionData = targetGridNo;//FindClosestClimbPoint(pSoldier, fUp );
if ( pSoldier->bActionPoints > GetAPsToClimbRoof ( pSoldier, fUp ) )
{
pSoldier->aiData.usActionData = targetGridNo;//FindClosestClimbPoint(pSoldier, fUp );
// Necessary test: can we climb up at this position? It might happen that our target is directly above us, then we'll have to move
INT8 newdirection;
if ( ( fUp && FindHeigherLevel( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &newdirection ) ) || ( !fUp && FindLowerLevel( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &newdirection ) ) )
{
return( AI_ACTION_CLIMB_ROOF );
}
else
{
return(AI_ACTION_SEEK_OPPONENT);
}
// Necessary test: can we climb up at this position? It might happen that our target is directly above us, then we'll have to move
INT8 newdirection;
if ( ( fUp && FindHeigherLevel( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &newdirection ) ) || ( !fUp && FindLowerLevel( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &newdirection ) ) )
{
return( AI_ACTION_CLIMB_ROOF );
}
}
else
{
return(AI_ACTION_SEEK_OPPONENT);
}
}
}
}