mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
Added memory leak detection to "new" operator
Prevent merc in slot 0 from disappearing due to errant schedule. Still need to find and fix schedule though Prevent attempts to turn or climb roof when soldier collapsed Fix problems when mortar or RPG randomly assigned to a soldier but cannot be added for whatever reason Pathing favors beginning path on orthogonal and using as few turns as possible (mostly old behavior). Prevent interruptions when soldier climbs up, which can cause fall into building just below the target roof position Fix pauses due to soldiers hurt in previous turn Fix soldier path not reaching destination when thrown by explosion damage or heavy gunfire Restore pathing to cave and underground exits Fix too many AI ending up on the roofs git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1588 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+29
-19
@@ -924,7 +924,7 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier)
|
||||
// CLIMB A BUILDING
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (!fCivilian)
|
||||
if (!fCivilian && pSoldier->bLastAction != AI_ACTION_CLIMB_ROOF)
|
||||
{
|
||||
iChance = 10 + pSoldier->bBypassToGreen;
|
||||
|
||||
@@ -965,30 +965,40 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier)
|
||||
// reduce chance if breath is down
|
||||
//iChance -= (100 - pSoldier->bBreath); // don't care
|
||||
|
||||
// This is the chance that we want to be on the roof. If already there, invert the chance to see if we want back
|
||||
// down
|
||||
if (pSoldier->bLevel > 0)
|
||||
{
|
||||
iChance = 100 - iChance;
|
||||
}
|
||||
|
||||
if ((INT16) PreRandom(100) < iChance)
|
||||
{
|
||||
BOOLEAN fUp = FALSE;
|
||||
if ( pSoldier->bLevel == 0 )
|
||||
{
|
||||
BOOLEAN fUp = TRUE;
|
||||
if (pSoldier->bLevel > 0 )
|
||||
fUp = FALSE;
|
||||
fUp = TRUE;
|
||||
}
|
||||
else if (pSoldier->bLevel > 0 )
|
||||
{
|
||||
fUp = FALSE;
|
||||
}
|
||||
|
||||
if ( CanClimbFromHere ( pSoldier, fUp ) )
|
||||
if ( CanClimbFromHere ( pSoldier, fUp ) )
|
||||
{
|
||||
DebugMsg ( TOPIC_JA2AI , DBG_LEVEL_3 , String("Soldier %d is climbing roof",pSoldier->ubID) );
|
||||
return( AI_ACTION_CLIMB_ROOF );
|
||||
}
|
||||
else
|
||||
{
|
||||
pSoldier->usActionData = FindClosestClimbPoint(pSoldier, fUp );
|
||||
// Added the check here because sniper militia who are locked inside of a building without keys
|
||||
// will still have a >100% chance to want to climb, which means an infinite loop. In fact, any
|
||||
// time a move is desired, there probably also will be a need to check for a path.
|
||||
if ( pSoldier->usActionData != NOWHERE &&
|
||||
LegalNPCDestination(pSoldier,pSoldier->usActionData,ENSURE_PATH,WATEROK, 0 ))
|
||||
{
|
||||
DebugMsg ( TOPIC_JA2AI , DBG_LEVEL_3 , String("Soldier %d is climbing roof",pSoldier->ubID) );
|
||||
return( AI_ACTION_CLIMB_ROOF );
|
||||
}
|
||||
else
|
||||
{
|
||||
pSoldier->usActionData = FindClosestClimbPoint(pSoldier, fUp );
|
||||
// Added the check here because sniper militia who are locked inside of a building without keys
|
||||
// will still have a >100% chance to want to climb, which means an infinite loop. In fact, any
|
||||
// time a move is desired, there probably also will be a need to check for a path.
|
||||
if ( pSoldier->usActionData != NOWHERE &&
|
||||
LegalNPCDestination(pSoldier,pSoldier->usActionData,ENSURE_PATH,WATEROK, 0 ))
|
||||
{
|
||||
return( AI_ACTION_MOVE_TO_CLIMB );
|
||||
}
|
||||
return( AI_ACTION_MOVE_TO_CLIMB );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user