mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
- New Feature: enemies roles allows the AI to use medics and officers, and the player can now identify high-value targets among the enemy.
Requires GameDir >= r1987. - If an enemy is spawned with a radio set, he is more likely to become a radio operator. - It is now possible to mount a gun on prone allies if you are facing them on the right angle. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7072 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -2305,6 +2305,13 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier)
|
||||
}
|
||||
break;
|
||||
|
||||
case AI_ACTION_DOCTOR:
|
||||
{
|
||||
pSoldier->AIDoctorFriend();
|
||||
ActionDone( pSoldier );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
#ifdef BETAVERSION
|
||||
NumMessage("ExecuteAction - Illegal action type = ",pSoldier->aiData.bAction);
|
||||
|
||||
+68
-15
@@ -594,6 +594,10 @@ BOOLEAN IsActionAffordable(SOLDIERTYPE *pSoldier)
|
||||
bMinPointsNeeded = 10; // TODO
|
||||
break;
|
||||
|
||||
case AI_ACTION_DOCTOR:
|
||||
bMinPointsNeeded = 20; // TODO
|
||||
break;
|
||||
|
||||
default:
|
||||
#ifdef BETAVERSION
|
||||
//NumMessage("AffordableAction - Illegal action type = ",pSoldier->aiData.bAction);
|
||||
@@ -3064,40 +3068,44 @@ INT32 CalcStraightThreatValue( SOLDIERTYPE *pEnemy )
|
||||
// Flugente: get the id of the closest soldier with a specific flag that we can currently see
|
||||
UINT8 GetClosestFlaggedSoldierID( SOLDIERTYPE * pSoldier, INT16 aRange, UINT8 auTeam, UINT32 aFlag )
|
||||
{
|
||||
UINT8 id = NOBODY;
|
||||
|
||||
UINT8 id = NOBODY;
|
||||
UINT32 uiLoop;
|
||||
BOOLEAN fRangeRestricted = FALSE, fFound = FALSE;
|
||||
SOLDIERTYPE * pFriend;
|
||||
INT16 range = aRange;
|
||||
|
||||
// go through each soldier, looking for "friends" (soldiers on same side)
|
||||
for (uiLoop = 0; uiLoop < guiNumMercSlots; ++uiLoop)
|
||||
// go through each soldier, looking for "friends" (soldiers on same team)
|
||||
for (uiLoop = gTacticalStatus.Team[ auTeam ].bFirstID; uiLoop < gTacticalStatus.Team[ auTeam ].bLastID; ++uiLoop)
|
||||
{
|
||||
pFriend = MercSlots[ uiLoop ];
|
||||
pFriend = MercPtrs[ uiLoop ];
|
||||
|
||||
// if this merc is inactive, not in sector, or dead
|
||||
if (!pFriend)
|
||||
continue;
|
||||
|
||||
// skip ourselves
|
||||
if (pFriend->ubID == pSoldier->ubID)
|
||||
continue;
|
||||
|
||||
// must be on the same level
|
||||
if ( pFriend->pathing.bLevel != pSoldier->pathing.bLevel )
|
||||
continue;
|
||||
|
||||
if ( auTeam != pFriend->bTeam )
|
||||
// skip if this guy is dead
|
||||
if ( pFriend->stats.bLife <= 0 )
|
||||
continue;
|
||||
|
||||
// check for flag
|
||||
if ( !(pFriend->bSoldierFlagMask & aFlag) )
|
||||
continue;
|
||||
|
||||
// skip ourselves
|
||||
if (pFriend->ubID == pSoldier->ubID)
|
||||
continue;
|
||||
|
||||
// if we're not already neighbors
|
||||
if (SpacesAway(pSoldier->sGridNo, pFriend->sGridNo) < range)
|
||||
|
||||
// are we close enough?
|
||||
INT16 friendrange = SpacesAway(pSoldier->sGridNo, pFriend->sGridNo);
|
||||
if ( friendrange < range)
|
||||
{
|
||||
// can we see this guy?
|
||||
if ( SoldierTo3DLocationLineOfSightTest( pSoldier, pFriend->sGridNo, pSoldier->pathing.bLevel, 3, TRUE, CALC_FROM_WANTED_DIR ) )
|
||||
{
|
||||
range = SpacesAway(pSoldier->sGridNo,pFriend->sGridNo);
|
||||
range = friendrange;
|
||||
id = pFriend->ubID;
|
||||
}
|
||||
}
|
||||
@@ -3105,3 +3113,48 @@ UINT8 GetClosestFlaggedSoldierID( SOLDIERTYPE * pSoldier, INT16 aRange, UINT8 au
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
// get the id of the closest soldier (closer than x tiles) of a specific team that is wounded that we can currently see
|
||||
UINT8 GetClosestWoundedSoldierID( SOLDIERTYPE * pSoldier, INT16 aRange, UINT8 auTeam )
|
||||
{
|
||||
UINT8 id = NOBODY;
|
||||
UINT32 uiLoop;
|
||||
SOLDIERTYPE * pFriend;
|
||||
INT16 range = aRange;
|
||||
|
||||
// go through each soldier, looking for "friends" (soldiers on same team)
|
||||
for (uiLoop = gTacticalStatus.Team[ auTeam ].bFirstID; uiLoop < gTacticalStatus.Team[ auTeam ].bLastID; ++uiLoop)
|
||||
{
|
||||
pFriend = MercPtrs[ uiLoop ];
|
||||
|
||||
// if this merc is inactive, not in sector, or dead
|
||||
if (!pFriend)
|
||||
continue;
|
||||
|
||||
// skip ourselves
|
||||
if (pFriend->ubID == pSoldier->ubID)
|
||||
continue;
|
||||
|
||||
// must be on the same level
|
||||
if ( pFriend->pathing.bLevel != pSoldier->pathing.bLevel )
|
||||
continue;
|
||||
|
||||
// skip if this guy is dead, not wounded or cannot be healed
|
||||
if ( pFriend->stats.bLife <= 0 || pFriend->iHealableInjury <= 0 || pFriend->stats.bLife >= pFriend->stats.bLifeMax )
|
||||
continue;
|
||||
|
||||
// are we close enough?
|
||||
INT16 friendrange = SpacesAway(pSoldier->sGridNo, pFriend->sGridNo);
|
||||
if ( friendrange < range)
|
||||
{
|
||||
// can we see this guy?
|
||||
if ( SoldierTo3DLocationLineOfSightTest( pSoldier, pFriend->sGridNo, pSoldier->pathing.bLevel, 3, TRUE, CALC_FROM_WANTED_DIR ) )
|
||||
{
|
||||
range = friendrange;
|
||||
id = pFriend->ubID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
+126
-1
@@ -930,6 +930,48 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier)
|
||||
return( AI_ACTION_RED_ALERT );
|
||||
}
|
||||
}
|
||||
|
||||
// if we are a doctor with medical gear, we might be able to help a wounded ally
|
||||
if ( pSoldier->CanMedicAI() )
|
||||
{
|
||||
UINT8 ubPerson = GetClosestWoundedSoldierID( pSoldier, gGameExternalOptions.sEnemyMedicsSearchRadius, pSoldier->bTeam);
|
||||
|
||||
if ( ubPerson != NOBODY )
|
||||
{
|
||||
if ( PythSpacesAway(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo) < 2 )
|
||||
{
|
||||
// see if we are facing this person
|
||||
UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo));
|
||||
|
||||
// if not already facing in that direction,
|
||||
if ( pSoldier->ubDirection != ubDesiredMercDir )
|
||||
{
|
||||
pSoldier->aiData.usActionData = ubDesiredMercDir;
|
||||
|
||||
return( AI_ACTION_CHANGE_FACING );
|
||||
}
|
||||
|
||||
// if not already crouched, crouch down first
|
||||
if ( gAnimControl[ pSoldier->usAnimState ].ubHeight != ANIM_CROUCH && IsValidStance( pSoldier, ANIM_CROUCH ) && GetAPsToChangeStance( pSoldier, ANIM_CROUCH ) <= pSoldier->bActionPoints )
|
||||
{
|
||||
pSoldier->aiData.usActionData = ANIM_CROUCH;
|
||||
|
||||
return(AI_ACTION_CHANGE_STANCE);
|
||||
}
|
||||
|
||||
return(AI_ACTION_DOCTOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSoldier->aiData.usActionData = InternalGoAsFarAsPossibleTowards(pSoldier, MercPtrs[ubPerson]->sGridNo, 20, AI_ACTION_SEEK_FRIEND, 0);
|
||||
|
||||
if (!TileIsOutOfBounds(pSoldier->aiData.usActionData))
|
||||
{
|
||||
return(AI_ACTION_SEEK_FRIEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//ddd}
|
||||
|
||||
@@ -1528,7 +1570,6 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier)
|
||||
// IF YOU SEE CAPTURED FRIENDS, FREE THEM!
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Flugente: if we see one of our buddies in handcuffs, its a clear sign of enemy activity!
|
||||
// Flugente: if we see one of our buddies captured, it is a clear sign of enemy activity!
|
||||
if ( gGameExternalOptions.fAllowPrisonerSystem && pSoldier->bTeam == ENEMY_TEAM )
|
||||
{
|
||||
@@ -1572,6 +1613,48 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we are a doctor with medical gear, we might be able to help a wounded ally
|
||||
if ( pSoldier->CanMedicAI() )
|
||||
{
|
||||
UINT8 ubPerson = GetClosestWoundedSoldierID( pSoldier, gGameExternalOptions.sEnemyMedicsSearchRadius, pSoldier->bTeam);
|
||||
|
||||
if ( ubPerson != NOBODY )
|
||||
{
|
||||
if ( PythSpacesAway(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo) < 2 )
|
||||
{
|
||||
// see if we are facing this person
|
||||
UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo));
|
||||
|
||||
// if not already facing in that direction,
|
||||
if ( pSoldier->ubDirection != ubDesiredMercDir )
|
||||
{
|
||||
pSoldier->aiData.usActionData = ubDesiredMercDir;
|
||||
|
||||
return( AI_ACTION_CHANGE_FACING );
|
||||
}
|
||||
|
||||
// if not already crouched, crouch down first
|
||||
if ( gAnimControl[ pSoldier->usAnimState ].ubHeight != ANIM_CROUCH && IsValidStance( pSoldier, ANIM_CROUCH ) && GetAPsToChangeStance( pSoldier, ANIM_CROUCH ) <= pSoldier->bActionPoints )
|
||||
{
|
||||
pSoldier->aiData.usActionData = ANIM_CROUCH;
|
||||
|
||||
return(AI_ACTION_CHANGE_STANCE);
|
||||
}
|
||||
|
||||
return(AI_ACTION_DOCTOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSoldier->aiData.usActionData = InternalGoAsFarAsPossibleTowards(pSoldier, MercPtrs[ubPerson]->sGridNo, 20, AI_ACTION_SEEK_FRIEND, 0);
|
||||
|
||||
if (!TileIsOutOfBounds(pSoldier->aiData.usActionData))
|
||||
{
|
||||
return(AI_ACTION_SEEK_FRIEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -2854,6 +2937,48 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we are a doctor with medical gear, we might be able to help a wounded ally
|
||||
if ( pSoldier->CanMedicAI() )
|
||||
{
|
||||
UINT8 ubPerson = GetClosestWoundedSoldierID( pSoldier, gGameExternalOptions.sEnemyMedicsSearchRadius, pSoldier->bTeam);
|
||||
|
||||
if ( ubPerson != NOBODY )
|
||||
{
|
||||
if ( PythSpacesAway(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo) < 2 )
|
||||
{
|
||||
// see if we are facing this person
|
||||
UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo));
|
||||
|
||||
// if not already facing in that direction,
|
||||
if ( pSoldier->ubDirection != ubDesiredMercDir )
|
||||
{
|
||||
pSoldier->aiData.usActionData = ubDesiredMercDir;
|
||||
|
||||
return( AI_ACTION_CHANGE_FACING );
|
||||
}
|
||||
|
||||
// if not already crouched, crouch down first
|
||||
if ( gAnimControl[ pSoldier->usAnimState ].ubHeight != ANIM_CROUCH && IsValidStance( pSoldier, ANIM_CROUCH ) && GetAPsToChangeStance( pSoldier, ANIM_CROUCH ) <= pSoldier->bActionPoints )
|
||||
{
|
||||
pSoldier->aiData.usActionData = ANIM_CROUCH;
|
||||
|
||||
return(AI_ACTION_CHANGE_STANCE);
|
||||
}
|
||||
|
||||
return(AI_ACTION_DOCTOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSoldier->aiData.usActionData = InternalGoAsFarAsPossibleTowards(pSoldier, MercPtrs[ubPerson]->sGridNo, 20, AI_ACTION_SEEK_FRIEND, 0);
|
||||
|
||||
if (!TileIsOutOfBounds(pSoldier->aiData.usActionData))
|
||||
{
|
||||
return(AI_ACTION_SEEK_FRIEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -104,6 +104,7 @@ typedef enum
|
||||
AI_ACTION_JUMP_WINDOW, // added by Flugente: jump through a window
|
||||
AI_ACTION_FREE_PRISONER, // added by Flugente: free a prisoner
|
||||
AI_ACTION_USE_SKILL, // added by Flugente: perform a skill, which one is stored in usAISkillUse
|
||||
AI_ACTION_DOCTOR, // added by Flugente: AI-ONLY! bandage/surgery on fellow AI. DO NOT USE THIS FOR MERCS!!!
|
||||
} ActionType;
|
||||
|
||||
|
||||
@@ -262,4 +263,7 @@ UINT8 NumberOfTeamMatesAdjacent( SOLDIERTYPE * pSoldier, INT32 sGridNo );
|
||||
// Flugente: get the id of the closest soldier (coser than x tiles) of a specific team with a specific flag that we can currently see
|
||||
UINT8 GetClosestFlaggedSoldierID( SOLDIERTYPE * pSoldier, INT16 aRange, UINT8 auTeam, UINT32 aFlag );
|
||||
|
||||
// get the id of the closest soldier (closer than x tiles) of a specific team that is wounded that we can currently see
|
||||
UINT8 GetClosestWoundedSoldierID( SOLDIERTYPE * pSoldier, INT16 aRange, UINT8 auTeam );
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user