Merged New Inventory Project into main branch

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1871 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
lalien
2008-03-08 15:15:25 +00:00
parent e16d166277
commit 43ca24dda8
649 changed files with 93359 additions and 82507 deletions
+32 -27
View File
@@ -3,7 +3,7 @@
#else
#include "types.h"
#include "wcheck.h"
#include "Soldier Control.h"
#include "Soldier Functions.h"
#include "ai.h"
#include "AIInternals.h"
@@ -17,10 +17,15 @@
#include "Assignments.h"
#endif
//forward declarations of common classes to eliminate includes
class OBJECTTYPE;
class SOLDIERTYPE;
extern BOOLEAN gfAutoBandageFailed;
//
// This file contains code devoted to the player AI-controlled medical system. Maybe it
// This file contains code devoted to the player AI-controlled medical system. Maybe it
// can be used or adapted for the enemies too...
//
@@ -78,8 +83,8 @@ BOOLEAN FullPatientCheck( SOLDIERTYPE * pPatient )
return( TRUE );
}
if ( pPatient->bLevel != 0 )
{ // look for a clear spot for jumping up
if ( pPatient->pathing.bLevel != 0 )
{ // look for a clear spot for jumping up
// special "closest" search that ignores climb spots IF they are occupied by non-medics
return( FindAutobandageClimbPoint( pPatient->sGridNo, TRUE ) );
@@ -94,14 +99,14 @@ BOOLEAN FullPatientCheck( SOLDIERTYPE * pPatient )
if ( CanCharacterAutoBandageTeammate( pSoldier ) == TRUE )
{
// can this guy path to the patient?
if ( pSoldier->bLevel == 0 )
if ( pSoldier->pathing.bLevel == 0 )
{
// do a regular path check
if ( FindBestPath( pSoldier, pPatient->sGridNo, 0, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) )
{
return( TRUE );
}
}
}
else
{
// if on different levels, assume okay
@@ -189,13 +194,13 @@ BOOLEAN CanCharacterAutoBandageTeammate( SOLDIERTYPE *pSoldier )
// can this soldier autobandage others in sector
{
// if the soldier isn't active or in sector, we have problems..leave
if ( !(pSoldier->bActive) || !(pSoldier->bInSector) || ( pSoldier->uiStatusFlags & SOLDIER_VEHICLE ) || (pSoldier->bAssignment == VEHICLE ) )
if ( !(pSoldier->bActive) || !(pSoldier->bInSector) || ( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE ) || (pSoldier->bAssignment == VEHICLE ) )
{
return( FALSE );
}
// they must have oklife or more, not be collapsed, have some level of medical competence, and have a med kit of some sort
if ( (pSoldier->bLife >= OKLIFE) && !(pSoldier->bCollapsed) && (pSoldier->bMedical > 0) && (FindObjClass( pSoldier, IC_MEDKIT ) != NO_SLOT) )
if ( (pSoldier->stats.bLife >= OKLIFE) && !(pSoldier->bCollapsed) && (pSoldier->stats.bMedical > 0) && (FindObjClass( pSoldier, IC_MEDKIT ) != NO_SLOT) )
{
return( TRUE );
}
@@ -208,12 +213,12 @@ BOOLEAN CanCharacterAutoBandageTeammate( SOLDIERTYPE *pSoldier )
BOOLEAN CanCharacterBeAutoBandagedByTeammate( SOLDIERTYPE *pSoldier )
{
// if the soldier isn't active or in sector, we have problems..leave
if ( !(pSoldier->bActive) || !(pSoldier->bInSector) || ( pSoldier->uiStatusFlags & SOLDIER_VEHICLE ) || (pSoldier->bAssignment == VEHICLE ) )
if ( !(pSoldier->bActive) || !(pSoldier->bInSector) || ( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE ) || (pSoldier->bAssignment == VEHICLE ) )
{
return( FALSE );
}
if ( (pSoldier->bLife > 0) && (pSoldier->bBleeding > 0) )
if ( (pSoldier->stats.bLife > 0) && (pSoldier->bBleeding > 0) )
{
// someone's bleeding and not being given first aid!
return( TRUE );
@@ -248,13 +253,13 @@ INT8 FindBestPatient( SOLDIERTYPE * pSoldier, BOOLEAN * pfDoClimb )
continue; // NEXT!!!
}
if (pPatient->bLife > 0 && pPatient->bBleeding && pPatient->ubServiceCount == 0)
if (pPatient->stats.bLife > 0 && pPatient->bBleeding && pPatient->ubServiceCount == 0)
{
if (pPatient->bLife < OKLIFE)
if (pPatient->stats.bLife < OKLIFE)
{
bPatientPriority = 3;
}
else if (pPatient->bLife < OKLIFE * 2)
else if (pPatient->stats.bLife < OKLIFE * 2)
{
bPatientPriority = 2;
}
@@ -265,7 +270,7 @@ INT8 FindBestPatient( SOLDIERTYPE * pSoldier, BOOLEAN * pfDoClimb )
if (bPatientPriority >= bBestPriority)
{
if ( !ClimbingNecessary( pSoldier, pPatient->sGridNo, pPatient->bLevel ) )
if ( !ClimbingNecessary( pSoldier, pPatient->sGridNo, pPatient->pathing.bLevel ) )
{
sPatientGridNo = pPatient->sGridNo;
@@ -276,7 +281,7 @@ INT8 FindBestPatient( SOLDIERTYPE * pSoldier, BOOLEAN * pfDoClimb )
for ( cnt2 = 0; cnt2 < NUM_WORLD_DIRECTIONS; cnt2++ )
{
sPatientGridNo = pPatient->sGridNo + DirectionInc( cnt2 );
if ( WhoIsThere2( sPatientGridNo, pPatient->bLevel ) == pPatient->ubID )
if ( WhoIsThere2( sPatientGridNo, pPatient->pathing.bLevel ) == pPatient->ubID )
{
// patient is also here, try this location
sAdjacentGridNo = FindAdjacentGridEx( pSoldier, sPatientGridNo, &ubDirection, &sAdjustedGridNo, FALSE, FALSE );
@@ -353,7 +358,7 @@ INT8 FindBestPatient( SOLDIERTYPE * pSoldier, BOOLEAN * pfDoClimb )
{
sClimbGridNo = NOWHERE;
// see if guy on another building etc and we need to climb somewhere
sPathCost = EstimatePathCostToLocation( pSoldier, pPatient->sGridNo, pPatient->bLevel, FALSE, &fClimbingNecessary, &sClimbGridNo );
sPathCost = EstimatePathCostToLocation( pSoldier, pPatient->sGridNo, pPatient->pathing.bLevel, FALSE, &fClimbingNecessary, &sClimbGridNo );
// if we can get there
if ( sPathCost != 0 && fClimbingNecessary && sPathCost < sShortestClimbPath )
{
@@ -381,19 +386,19 @@ INT8 FindBestPatient( SOLDIERTYPE * pSoldier, BOOLEAN * pfDoClimb )
*pfDoClimb = FALSE;
if ( CardinalSpacesAway( pSoldier->sGridNo, sBestPatientGridNo ) == 1 )
{
pSoldier->usActionData = sBestPatientGridNo;
pSoldier->aiData.usActionData = sBestPatientGridNo;
return( AI_ACTION_GIVE_AID );
}
else
{
pSoldier->usActionData = sBestAdjGridNo;
pSoldier->aiData.usActionData = sBestAdjGridNo;
return( AI_ACTION_GET_CLOSER );
}
}
else if (sBestClimbGridNo != NOWHERE )
{
*pfDoClimb = TRUE;
pSoldier->usActionData = sBestClimbGridNo;
pSoldier->aiData.usActionData = sBestClimbGridNo;
return( AI_ACTION_MOVE_TO_CLIMB );
}
else
@@ -408,7 +413,7 @@ INT8 DecideAutoBandage( SOLDIERTYPE * pSoldier )
BOOLEAN fDoClimb;
if (pSoldier->bMedical == 0 || pSoldier->ubServicePartner != NOBODY)
if (pSoldier->stats.bMedical == 0 || pSoldier->ubServicePartner != NOBODY)
{
// don't/can't make decision
return( AI_ACTION_NONE );
@@ -424,7 +429,7 @@ INT8 DecideAutoBandage( SOLDIERTYPE * pSoldier )
if (pSoldier->bBleeding)
{
// heal self first!
pSoldier->usActionData = pSoldier->sGridNo;
pSoldier->aiData.usActionData = pSoldier->sGridNo;
if (bSlot != HANDPOS)
{
pSoldier->bSlotItemTakenFrom = bSlot;
@@ -443,9 +448,9 @@ INT8 DecideAutoBandage( SOLDIERTYPE * pSoldier )
return( AI_ACTION_GIVE_AID );
}
// pSoldier->usActionData = FindClosestPatient( pSoldier );
pSoldier->bAction = FindBestPatient( pSoldier, &fDoClimb );
if (pSoldier->bAction != AI_ACTION_NONE)
// pSoldier->aiData.usActionData = FindClosestPatient( pSoldier );
pSoldier->aiData.bAction = FindBestPatient( pSoldier, &fDoClimb );
if (pSoldier->aiData.bAction != AI_ACTION_NONE)
{
pSoldier->usUIMovementMode = RUNNING;
if (bSlot != HANDPOS)
@@ -454,9 +459,9 @@ INT8 DecideAutoBandage( SOLDIERTYPE * pSoldier )
SwapObjs( pSoldier, HANDPOS, bSlot, TRUE );
}
return( pSoldier->bAction );
return( pSoldier->aiData.bAction );
}
// do nothing
return( AI_ACTION_NONE );
}
return( AI_ACTION_NONE );
}