mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
- AI controlled soldiers can now jump through windows
- new ini option allows to jump through closed windows, smashing them while doing so git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5682 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+145
-2
@@ -5300,6 +5300,106 @@ INT16 ubMinAPCost;
|
||||
return( AI_ACTION_NONE );
|
||||
}
|
||||
|
||||
// get the location of the closest reachable opponent
|
||||
/* Flugente 22.02.2012 - A few clarifications: I changed ClosestSeenOpponent so that for zombies, this function also returns an opponent if he is on the
|
||||
* roof of a building, we are not, but our GridNo belongs to that same building.
|
||||
* If that is the case, it is clear that we have to get on that roof. However, we cannot do that in BlackState. If, by pure chance, we can still see our
|
||||
* enemy, we cannot climb (there is no climbing option in BlackState sofar).
|
||||
* So, I changed the code so that now we will climb the roof.
|
||||
*/
|
||||
INT32 targetGridNo = -1;
|
||||
INT8 targetbLevel = 0;
|
||||
sClosestOpponent = ClosestSeenOpponentWithRoof(pSoldier, &targetGridNo, &targetbLevel);
|
||||
if (!TileIsOutOfBounds(sClosestOpponent) && ! ( (targetbLevel != pSoldier->pathing.bLevel) && SameBuilding( pSoldier->sGridNo, targetGridNo ) ) )
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// GO DIRECTLY TOWARDS CLOSEST KNOWN OPPONENT
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// try to move towards him
|
||||
pSoldier->aiData.usActionData = GoAsFarAsPossibleTowards(pSoldier,sClosestOpponent,AI_ACTION_GET_CLOSER);
|
||||
|
||||
// if it's possible
|
||||
if (!TileIsOutOfBounds(sClosestOpponent))
|
||||
{
|
||||
if (targetbLevel != pSoldier->pathing.bLevel )
|
||||
return(AI_ACTION_MOVE_TO_CLIMB);
|
||||
else
|
||||
{
|
||||
// Flugente: if on the same level and there is a jumpable window here, jump through it
|
||||
if ( gGameExternalOptions.fCanJumpThroughWindows && targetbLevel == pSoldier->pathing.bLevel && targetbLevel == 0 )
|
||||
{
|
||||
// determine if there is a jumpable window in the direction to our target
|
||||
// if yes, and we are not facing it, face it now
|
||||
// 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);
|
||||
|
||||
// determine if there is a jumpable window here, in the direction of our target
|
||||
// store old direction for this check
|
||||
INT tmpdirection = pSoldier->ubDirection;
|
||||
pSoldier->ubDirection = targetdirection;
|
||||
|
||||
INT8 windowdirection = DIRECTION_IRRELEVANT;
|
||||
if ( FindWindowJumpDirection(pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &windowdirection) && targetdirection == windowdirection )
|
||||
{
|
||||
pSoldier->ubDirection = tmpdirection;
|
||||
|
||||
// are we already looking in that direction?
|
||||
if ( pSoldier->ubDirection == targetdirection )
|
||||
{
|
||||
// jump through the window
|
||||
return(AI_ACTION_JUMP_WINDOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
// look into that direction
|
||||
if ( pSoldier->InternalIsValidStance( targetdirection, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
|
||||
{
|
||||
pSoldier->aiData.usActionData = targetdirection;
|
||||
return(AI_ACTION_CHANGE_FACING);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pSoldier->ubDirection = tmpdirection;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// The situation mentioned above happens...
|
||||
else if ( (targetbLevel != pSoldier->pathing.bLevel) && SameBuilding( pSoldier->sGridNo, targetGridNo ) )
|
||||
{
|
||||
if ( 1 )//gGameExternalOptions.fZombieCanClimb )
|
||||
{
|
||||
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 ) )
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// try to make boxer close if possible
|
||||
if (pSoldier->flags.uiStatusFlags & SOLDIER_BOXER )
|
||||
{
|
||||
@@ -7853,7 +7953,7 @@ void DecideAlertStatus( SOLDIERTYPE *pSoldier )
|
||||
*/
|
||||
INT32 targetGridNo = -1;
|
||||
INT8 targetbLevel = 0;
|
||||
sClosestOpponent = ClosestSeenOpponentforZombie(pSoldier, &targetGridNo, &targetbLevel);
|
||||
sClosestOpponent = ClosestSeenOpponentWithRoof(pSoldier, &targetGridNo, &targetbLevel);
|
||||
if ( pSoldier->ubSoldierClass == SOLDIER_CLASS_ZOMBIE )
|
||||
{
|
||||
if (!TileIsOutOfBounds(sClosestOpponent) && ! ( (targetbLevel != pSoldier->pathing.bLevel) && SameBuilding( pSoldier->sGridNo, targetGridNo ) ) )
|
||||
@@ -7866,14 +7966,57 @@ void DecideAlertStatus( SOLDIERTYPE *pSoldier )
|
||||
pSoldier->aiData.usActionData = GoAsFarAsPossibleTowards(pSoldier,sClosestOpponent,AI_ACTION_GET_CLOSER);
|
||||
|
||||
// if it's possible
|
||||
if (!TileIsOutOfBounds(pSoldier->aiData.usActionData))
|
||||
if (!TileIsOutOfBounds(sClosestOpponent))
|
||||
{
|
||||
if (targetbLevel != pSoldier->pathing.bLevel && gGameExternalOptions.fZombieCanClimb )
|
||||
return(AI_ACTION_MOVE_TO_CLIMB);
|
||||
else
|
||||
{
|
||||
// Flugente: if on the same level and there is a jumpable window here, jump through it
|
||||
if ( gGameExternalOptions.fZombieCanJumpWindows && targetbLevel == pSoldier->pathing.bLevel && targetbLevel == 0 )
|
||||
{
|
||||
// determine if there is a jumpable window in the direction to our target
|
||||
// if yes, and we are not facing it, face it now
|
||||
// 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);
|
||||
|
||||
// determine if there is a jumpable window here, in the direction of our target
|
||||
// store old direction for this check
|
||||
INT tmpdirection = pSoldier->ubDirection;
|
||||
pSoldier->ubDirection = targetdirection;
|
||||
|
||||
INT8 windowdirection = DIRECTION_IRRELEVANT;
|
||||
if ( FindWindowJumpDirection(pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &windowdirection) && targetdirection == windowdirection )
|
||||
{
|
||||
pSoldier->ubDirection = tmpdirection;
|
||||
|
||||
// are we already looking in that direction?
|
||||
if ( pSoldier->ubDirection == targetdirection )
|
||||
{
|
||||
// jump through the window
|
||||
return(AI_ACTION_JUMP_WINDOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
// look into that direction
|
||||
if ( pSoldier->InternalIsValidStance( targetdirection, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
|
||||
{
|
||||
pSoldier->aiData.usActionData = targetdirection;
|
||||
return(AI_ACTION_CHANGE_FACING);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pSoldier->ubDirection = tmpdirection;
|
||||
}
|
||||
|
||||
return(AI_ACTION_SEEK_OPPONENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
// The situation mentioned above happens...
|
||||
else if ( (targetbLevel != pSoldier->pathing.bLevel) && SameBuilding( pSoldier->sGridNo, targetGridNo ) )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user