mirror of
https://github.com/1dot13/source.git
synced 2026-08-19 14:20:30 +02:00
- New feature: zombies can now spawn from corpses, if you specify that option in the preferences screen (by Flugente)
o if set to off, no zombies will spawn. This can also be changed in mid-game o for more information on how this works and how to set it up, see http://www.bears-pit.com/board/ubbthreads.php/topics/295746/Zombies_WH40K_and_more.html#Post295746 o with the tag <PoisonPercentage>, you can now poison guns or ammo. This is the percentage of damage dealt that will be poisonous (see zombie thread for an explanation) o The zombie option can only be enabled in a single player game o AI fix: to prevent the endless clock problem, the AI now ends the turn if the same actor calls the decision routine over 100 times in a single turn. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5313 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -171,6 +171,14 @@ INT32 ClosestSeenOpponent(SOLDIERTYPE *pSoldier, INT32 * psGridNo, INT8 * pbLeve
|
||||
void CreatureCall( SOLDIERTYPE * pCaller );
|
||||
INT8 CreatureDecideAction( SOLDIERTYPE * pCreature );
|
||||
void CreatureDecideAlertStatus( SOLDIERTYPE *pCreature );
|
||||
|
||||
// Flugente: Zombie AI
|
||||
INT8 ZombieDecideAction( SOLDIERTYPE * pZombie );
|
||||
void ZombieDecideAlertStatus( SOLDIERTYPE *pZombie );
|
||||
|
||||
// a variant of ClosestSeenOpponent(...), that allows zombies
|
||||
INT32 ClosestSeenOpponentforZombie(SOLDIERTYPE *pSoldier, INT32 * psGridNo, INT8 * pbLevel);
|
||||
|
||||
INT8 CrowDecideAction( SOLDIERTYPE * pSoldier );
|
||||
void DecideAlertStatus( SOLDIERTYPE *pSoldier );
|
||||
INT8 DecideAutoBandage( SOLDIERTYPE * pSoldier );
|
||||
|
||||
+31
-1
@@ -1616,7 +1616,32 @@ fprintf(NetDebugFile,"\tNPC %d, dtctLvl %d, marking mine at gridno %d, gridCost
|
||||
|
||||
void TurnBasedHandleNPCAI(SOLDIERTYPE *pSoldier)
|
||||
{
|
||||
// added by Flugente: static pointers, used to break out of an endless circles (currently only used for zombie AI)
|
||||
static SOLDIERTYPE* pLastDecisionSoldier = NULL;
|
||||
static INT16 lastdecisioncount = 0;
|
||||
|
||||
// simple solution to prevent an endless clock: remember the last soldier that decided an action. If its the same one, increase the counter.
|
||||
// if counter is high enough, end this guy's turn
|
||||
if ( pSoldier == pLastDecisionSoldier )
|
||||
{
|
||||
// we will only end our turn this way if this function was called over 100 times with same soldier without ending a turn.
|
||||
// so many actions in a single turn smell of an endless clock.
|
||||
// If we end a turn normally, the counter will be set back to 0, so this wont be a problem if you have a single soldier left for multiple turns
|
||||
if ( lastdecisioncount >= 100 )
|
||||
{
|
||||
// zombie is done doing harm...
|
||||
EndAIGuysTurn( pSoldier);
|
||||
lastdecisioncount = 0;
|
||||
return ;
|
||||
}
|
||||
else
|
||||
++lastdecisioncount;
|
||||
}
|
||||
else
|
||||
{
|
||||
pLastDecisionSoldier = pSoldier;
|
||||
lastdecisioncount = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
if (Status.gamePaused)
|
||||
@@ -1905,7 +1930,11 @@ void TurnBasedHandleNPCAI(SOLDIERTYPE *pSoldier)
|
||||
{
|
||||
if (!(gTacticalStatus.uiFlags & ENGAGED_IN_CONV))
|
||||
{
|
||||
if (CREATURE_OR_BLOODCAT( pSoldier ))
|
||||
if ( pSoldier->IsZombie() )
|
||||
{
|
||||
pSoldier->aiData.bAction = ZombieDecideAction(pSoldier);
|
||||
}
|
||||
else if (CREATURE_OR_BLOODCAT( pSoldier ))
|
||||
{
|
||||
pSoldier->aiData.bAction = CreatureDecideAction( pSoldier );
|
||||
}
|
||||
@@ -1971,6 +2000,7 @@ void TurnBasedHandleNPCAI(SOLDIERTYPE *pSoldier)
|
||||
{
|
||||
// turn based... abort this guy's turn
|
||||
EndAIGuysTurn( pSoldier );
|
||||
lastdecisioncount = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1295,6 +1295,100 @@ INT32 ClosestSeenOpponent(SOLDIERTYPE *pSoldier, INT32 * psGridNo, INT8 * pbLeve
|
||||
}
|
||||
|
||||
|
||||
// special variant with a minor twist for the zombie AI
|
||||
INT32 ClosestSeenOpponentforZombie(SOLDIERTYPE *pSoldier, INT32 * psGridNo, INT8 * pbLevel)
|
||||
{
|
||||
INT32 sGridNo, sClosestOpponent = NOWHERE;
|
||||
UINT32 uiLoop;
|
||||
INT32 iRange, iClosestRange = 1500;
|
||||
INT8 *pbPersOL;
|
||||
INT8 bLevel, bClosestLevel;
|
||||
SOLDIERTYPE * pOpp;
|
||||
|
||||
bClosestLevel = -1;
|
||||
|
||||
// look through this man's personal & public opplists for opponents known
|
||||
for (uiLoop = 0; uiLoop < guiNumMercSlots; uiLoop++)
|
||||
{
|
||||
pOpp = MercSlots[ uiLoop ];
|
||||
|
||||
// if this merc is inactive, at base, on assignment, or dead
|
||||
if (!pOpp)
|
||||
{
|
||||
continue; // next merc
|
||||
}
|
||||
|
||||
// if this merc is neutral/on same side, he's not an opponent
|
||||
if ( CONSIDERED_NEUTRAL( pSoldier, pOpp ) || (pSoldier->bSide == pOpp->bSide))
|
||||
{
|
||||
continue; // next merc
|
||||
}
|
||||
|
||||
// Special stuff for Carmen the bounty hunter
|
||||
if (pSoldier->aiData.bAttitude == ATTACKSLAYONLY && pOpp->ubProfile != 64)
|
||||
{
|
||||
continue; // next opponent
|
||||
}
|
||||
|
||||
pbPersOL = pSoldier->aiData.bOppList + pOpp->ubID;
|
||||
|
||||
// if this opponent is not seen personally
|
||||
if (*pbPersOL != SEEN_CURRENTLY)
|
||||
{
|
||||
continue; // next merc
|
||||
}
|
||||
|
||||
// since we're dealing with seen people, use exact gridnos
|
||||
sGridNo = pOpp->sGridNo;
|
||||
bLevel = pOpp->pathing.bLevel;
|
||||
|
||||
// if we are standing at that gridno(!, obviously our info is old...)
|
||||
if (sGridNo == pSoldier->sGridNo)
|
||||
{
|
||||
continue; // next merc
|
||||
}
|
||||
|
||||
// special: allow zombies to also find opponents on a roof
|
||||
// otherwise they have will never decide to climb a roof while they are seeing an enemy
|
||||
// this function is used only for turning towards closest opponent or changing stance
|
||||
// as such, if they AI is in a building,
|
||||
// we should ignore people who are on the roof of the same building as the AI
|
||||
if ( !pSoldier->IsZombie() && (bLevel != pSoldier->pathing.bLevel) && SameBuilding( pSoldier->sGridNo, sGridNo ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// I hope this will be good enough; otherwise we need a fractional/world-units-based 2D distance function
|
||||
//sRange = PythSpacesAway( pSoldier->sGridNo, sGridNo);
|
||||
iRange = GetRangeInCellCoordsFromGridNoDiff( pSoldier->sGridNo, sGridNo );
|
||||
|
||||
if (iRange < iClosestRange)
|
||||
{
|
||||
iClosestRange = iRange;
|
||||
sClosestOpponent = sGridNo;
|
||||
bClosestLevel = bLevel;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUGDECISIONS
|
||||
if (!TileIsOutOfBounds(sClosestOpponent))
|
||||
{
|
||||
AINumMessage("CLOSEST OPPONENT is at gridno ",sClosestOpponent);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (psGridNo)
|
||||
{
|
||||
*psGridNo = sClosestOpponent;
|
||||
}
|
||||
if (pbLevel)
|
||||
{
|
||||
*pbLevel = bClosestLevel;
|
||||
}
|
||||
return( sClosestOpponent );
|
||||
}
|
||||
|
||||
|
||||
INT32 ClosestPC( SOLDIERTYPE *pSoldier, INT32 * psDistance )
|
||||
{
|
||||
// used by NPCs... find the closest PC
|
||||
@@ -2487,6 +2581,10 @@ UINT8 SoldierDifficultyLevel( SOLDIERTYPE * pSoldier )
|
||||
bDifficulty = 4;
|
||||
break;
|
||||
|
||||
case SOLDIER_CLASS_ZOMBIE:
|
||||
bDifficulty = bDifficultyBase;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (pSoldier->bTeam == CREATURE_TEAM)
|
||||
{
|
||||
|
||||
@@ -1757,3 +1757,4 @@ INT8 CrowDecideAction( SOLDIERTYPE * pSoldier )
|
||||
return( AI_ACTION_NONE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,6 +27,10 @@ INT8 RTPlayerDecideAction( SOLDIERTYPE * pSoldier )
|
||||
{
|
||||
bAction = DecideAutoBandage( pSoldier );
|
||||
}
|
||||
else if ( pSoldier->IsZombie() )
|
||||
{
|
||||
bAction = ZombieDecideAction( pSoldier );
|
||||
}
|
||||
else
|
||||
{
|
||||
bAction = DecideAction( pSoldier );
|
||||
@@ -47,6 +51,10 @@ INT8 RTDecideAction(SOLDIERTYPE *pSoldier)
|
||||
{
|
||||
return( CreatureDecideAction( pSoldier ) );
|
||||
}
|
||||
else if ( pSoldier->IsZombie() )
|
||||
{
|
||||
return( ZombieDecideAction( pSoldier ) );
|
||||
}
|
||||
else if (pSoldier->ubBodyType == CROW)
|
||||
{
|
||||
return( CrowDecideAction( pSoldier ) );
|
||||
|
||||
Reference in New Issue
Block a user