mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Fix for mouse movement when clicking on mercs. In windowed mode would move the cursor to odd places on screen
Enemy group invasion tactics fixed. Now reinforcements come from all directions, same as from surrounding stationary reinforcements Removed shuriken check Fix for mercs turing lame git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1154 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -1574,6 +1574,7 @@ BOOLEAN IsCursorRestricted( void )
|
||||
|
||||
void SimulateMouseMovement( UINT32 uiNewXPos, UINT32 uiNewYPos )
|
||||
{
|
||||
#if 0
|
||||
FLOAT flNewXPos, flNewYPos;
|
||||
|
||||
// Wizardry NOTE: This function currently doesn't quite work right for in any Windows resolution other than 640x480.
|
||||
@@ -1591,6 +1592,17 @@ void SimulateMouseMovement( UINT32 uiNewXPos, UINT32 uiNewYPos )
|
||||
flNewYPos = ( (FLOAT)uiNewYPos / SCREEN_HEIGHT ) * 65536;
|
||||
|
||||
mouse_event( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, (UINT32)flNewXPos, (UINT32)flNewYPos, 0, 0 );
|
||||
#endif
|
||||
// 0verhaul:
|
||||
// The above is a bad hack. Especially in windowed mode. We don't want coords relative to the entire screen in that case.
|
||||
// So instead, get screen coords and then use the setcursorpos call.
|
||||
POINT newmouse;
|
||||
newmouse.x = uiNewXPos;
|
||||
newmouse.y = uiNewYPos;
|
||||
ClientToScreen( ghWindow, &newmouse);
|
||||
SetCursorPos( newmouse.x, newmouse.y);
|
||||
|
||||
// Does this generate a mouse move message? I'll first try without
|
||||
}
|
||||
|
||||
|
||||
|
||||
+174
-95
@@ -50,6 +50,7 @@
|
||||
#endif
|
||||
|
||||
#include "Reinforcement.h"
|
||||
#include "MilitiaSquads.h"
|
||||
|
||||
//The sector information required for the strategic AI. Contains the number of enemy troops,
|
||||
//as well as intentions, etc.
|
||||
@@ -442,11 +443,41 @@ BOOLEAN PrepareEnemyForSectorBattle()
|
||||
if( gbWorldSectorZ > 0 )
|
||||
return PrepareEnemyForUndergroundBattle();
|
||||
|
||||
if( gpBattleGroup && !gpBattleGroup->fPlayer )
|
||||
{ //The enemy has instigated the battle which means they are the ones entering the conflict.
|
||||
// Reinforcement groups? Bring it on! That is, if this is an enemy invasion.
|
||||
if( gGameExternalOptions.gfAllowReinforcements &&
|
||||
!( (GetTownIdForSector( gWorldSectorX, gWorldSectorY ) == OMERTA )&&( gGameOptions.ubDifficultyLevel != DIF_LEVEL_INSANE ) ) &&
|
||||
gpBattleGroup && !gpBattleGroup->fPlayer )
|
||||
{
|
||||
UINT16 pusMoveDir[4][3];
|
||||
UINT8 ubDirNumber = 0, ubIndex;
|
||||
GROUP *pGroup;
|
||||
SECTORINFO *pThisSector;
|
||||
|
||||
//The enemy has instigated the battle which means they are the ones entering the conflict.
|
||||
//The player was actually in the sector first, and the enemy doesn't use reinforced placements
|
||||
HandleArrivalOfReinforcements( gpBattleGroup );
|
||||
//It is possible that other enemy groups have also arrived. Add them in the same manner.
|
||||
|
||||
// They arrived in multiple groups, so here they come
|
||||
pThisSector = &SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY ) ];
|
||||
|
||||
GenerateDirectionInfos( gWorldSectorX, gWorldSectorY, &ubDirNumber, pusMoveDir,
|
||||
( GetTownIdForSector( gWorldSectorX, gWorldSectorY ) != BLANK_SECTOR ? TRUE : FALSE ), TRUE, IS_ONLY_IN_CITIES );
|
||||
|
||||
for( ubIndex = 0; ubIndex < ubDirNumber; ubIndex++ )
|
||||
{
|
||||
while ( NumMobileEnemiesInSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) && GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) )
|
||||
{
|
||||
pGroup = GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) );
|
||||
|
||||
pGroup->ubPrevX = pGroup->ubSectorX;
|
||||
pGroup->ubPrevY = pGroup->ubSectorY;
|
||||
|
||||
pGroup->ubSectorX = pGroup->ubNextX = (UINT8)gWorldSectorX;
|
||||
pGroup->ubSectorY = pGroup->ubNextY = (UINT8)gWorldSectorY;
|
||||
}
|
||||
}
|
||||
|
||||
//It is now possible that other enemy groups have also arrived. Add them in the same manner.
|
||||
pGroup = gpGroupList;
|
||||
while( pGroup )
|
||||
{
|
||||
@@ -461,6 +492,7 @@ BOOLEAN PrepareEnemyForSectorBattle()
|
||||
}
|
||||
pGroup = pGroup->next;
|
||||
}
|
||||
|
||||
ValidateEnemiesHaveWeapons();
|
||||
return ( ( BOOLEAN) ( gpBattleGroup->ubGroupSize > 0 ) );
|
||||
}
|
||||
@@ -546,6 +578,11 @@ BOOLEAN PrepareEnemyForSectorBattle()
|
||||
ubTotalAdmins, ubTotalTroops, ubTotalElites );
|
||||
#endif
|
||||
}
|
||||
#if 0
|
||||
// 0verhaul: Not here. First this gives reinforcement groups the unfair advantage of being already placed.
|
||||
// Second, this particular loop is also used to reset strategic player groups in the sector so that they
|
||||
// can be given movement orders (why here though?), but would quit early if the enemy slots are filled.
|
||||
|
||||
//Subtract the total number of stationary enemies from the available slots, as stationary forces take
|
||||
//precendence in combat. The mobile forces that could also be in the same sector are considered later if
|
||||
//all the slots fill up.
|
||||
@@ -553,9 +590,12 @@ BOOLEAN PrepareEnemyForSectorBattle()
|
||||
//Now, process all of the groups and search for both enemy and player groups in the sector.
|
||||
//For enemy groups, we fill up the slots until we have none left or all of the groups have been
|
||||
//processed.
|
||||
pGroup = gpGroupList;
|
||||
while( pGroup && sNumSlots )
|
||||
#endif
|
||||
for( pGroup = gpGroupList;
|
||||
pGroup;
|
||||
pGroup = pGroup->next)
|
||||
{
|
||||
#if 0
|
||||
if( !pGroup->fPlayer && !pGroup->fVehicle &&
|
||||
pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ )
|
||||
{ //Process enemy group in sector.
|
||||
@@ -601,6 +641,8 @@ BOOLEAN PrepareEnemyForSectorBattle()
|
||||
//NOTE:
|
||||
//no provisions for profile troop leader or retreat groups yet.
|
||||
}
|
||||
#endif
|
||||
|
||||
if( pGroup->fPlayer && !pGroup->fVehicle && !pGroup->fBetweenSectors &&
|
||||
pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ )
|
||||
{ //TEMP: The player path needs to get destroyed, otherwise, it'll be impossible to move the
|
||||
@@ -609,14 +651,12 @@ BOOLEAN PrepareEnemyForSectorBattle()
|
||||
// no one in the group any more continue loop
|
||||
if( pGroup->pPlayerList == NULL )
|
||||
{
|
||||
pGroup = pGroup->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
// clear the movt for this grunt and his buddies
|
||||
RemoveGroupWaypoints( pGroup->ubGroupID );
|
||||
}
|
||||
pGroup = pGroup->next;
|
||||
}
|
||||
|
||||
//if there are no troops in the current groups, then we're done.
|
||||
@@ -627,6 +667,7 @@ BOOLEAN PrepareEnemyForSectorBattle()
|
||||
|
||||
AddSoldierInitListEnemyDefenceSoldiers( ubTotalAdmins, ubTotalTroops, ubTotalElites );
|
||||
|
||||
#if 0
|
||||
//Now, we have to go through all of the enemies in the new map, and assign their respective groups if
|
||||
//in a mobile group, but only for the ones that were assigned from the
|
||||
sNumSlots = 32 - ubStationaryEnemies;
|
||||
@@ -687,6 +728,7 @@ BOOLEAN PrepareEnemyForSectorBattle()
|
||||
}
|
||||
pGroup = pGroup->next;
|
||||
}
|
||||
#endif
|
||||
|
||||
ValidateEnemiesHaveWeapons();
|
||||
|
||||
@@ -1142,10 +1184,13 @@ void AddPossiblePendingEnemiesToBattle()
|
||||
{
|
||||
UINT8 ubSlots, ubNumAvailable;
|
||||
UINT8 ubNumElites, ubNumTroops, ubNumAdmins;
|
||||
UINT8 ubNumGroupsInSector;
|
||||
UINT8 ubGroupIndex;
|
||||
GROUP *pGroup;
|
||||
SECTORINFO *pSector = &SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY ) ];
|
||||
GROUP **pGroupInSectorList;
|
||||
static UINT8 ubPredefinedInsertionCode = 255;
|
||||
|
||||
|
||||
// check if no world is loaded
|
||||
if ( !gWorldSectorX && !gWorldSectorY && (gbWorldSectorZ == -1) )
|
||||
return;
|
||||
@@ -1153,24 +1198,55 @@ void AddPossiblePendingEnemiesToBattle()
|
||||
if( ( !PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, 0 ) && !CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY ) )
|
||||
|| !NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) ) return;
|
||||
|
||||
/* if( !gfPendingEnemies )
|
||||
{ //Optimization. No point in checking if we know that there aren't any more enemies that can
|
||||
//be added to this battle. This changes whenever a new enemy group arrives at the scene.
|
||||
return;
|
||||
}*/
|
||||
ubSlots = NumFreeEnemySlots();
|
||||
if( !ubSlots )
|
||||
{ //no available slots to add enemies to. Try again later...
|
||||
return;
|
||||
}
|
||||
|
||||
if( !gfPendingEnemies )
|
||||
{
|
||||
//Optimization. No point in checking for group reinforcements if we know that there aren't any more enemies that can
|
||||
//be added to this battle. This changes whenever a new enemy group arrives at the scene.
|
||||
|
||||
while (ubSlots)
|
||||
{
|
||||
UINT8 ubInsertionCode = 255;
|
||||
|
||||
if( gTacticalStatus.Team[ ENEMY_TEAM ].bAwareOfOpposition == TRUE )
|
||||
ubInsertionCode = DoReinforcementAsPendingEnemy( gWorldSectorX, gWorldSectorY );
|
||||
|
||||
if (ubInsertionCode == 255)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
AddEnemiesToBattle( pGroup, ubInsertionCode,
|
||||
pSector->ubNumAdmins - pSector->ubAdminsInBattle,
|
||||
pSector->ubNumTroops - pSector->ubTroopsInBattle,
|
||||
pSector->ubNumElites - pSector->ubElitesInBattle,
|
||||
FALSE );
|
||||
|
||||
pSector->ubAdminsInBattle = pSector->ubNumAdmins;
|
||||
pSector->ubTroopsInBattle = pSector->ubNumTroops;
|
||||
pSector->ubElitesInBattle = pSector->ubNumElites;
|
||||
|
||||
// Assume we added one since there are supposedly more available and room for them
|
||||
ubSlots--;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if( pSector->ubNumElites + pSector->ubNumTroops + pSector->ubNumAdmins )
|
||||
{
|
||||
ubNumElites = ubNumTroops = ubNumAdmins = 0;
|
||||
|
||||
ubNumAvailable = pSector->ubNumElites + pSector->ubNumTroops + pSector->ubNumAdmins - pSector->ubElitesInBattle - pSector->ubTroopsInBattle - pSector->ubAdminsInBattle;
|
||||
while( ubNumAvailable && ubSlots )
|
||||
{ //This group has enemies waiting for a chance to enter the battle.
|
||||
{
|
||||
// So they just magically appear out of nowhere from the edge?
|
||||
|
||||
//This group has enemies waiting for a chance to enter the battle.
|
||||
if( pSector->ubElitesInBattle < pSector->ubNumElites )
|
||||
{ //Add an elite troop
|
||||
pSector->ubElitesInBattle++;
|
||||
@@ -1239,94 +1315,97 @@ void AddPossiblePendingEnemiesToBattle()
|
||||
|
||||
ubPredefinedInsertionCode = 255;
|
||||
|
||||
pGroup = gpGroupList;
|
||||
while( pGroup && ubSlots )
|
||||
// Figure out which groups are in the sector, so we can have reinforcements arrive at random
|
||||
for (ubNumGroupsInSector = 0, pGroup = gpGroupList; pGroup; pGroup = pGroup->next)
|
||||
{
|
||||
if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ )
|
||||
{ //This enemy group is currently in the sector.
|
||||
ubNumElites = ubNumTroops = ubNumAdmins = 0;
|
||||
ubNumAvailable = pGroup->ubGroupSize - pGroup->pEnemyGroup->ubElitesInBattle - pGroup->pEnemyGroup->ubTroopsInBattle - pGroup->pEnemyGroup->ubAdminsInBattle;
|
||||
while( ubNumAvailable && ubSlots )
|
||||
{ //This group has enemies waiting for a chance to enter the battle.
|
||||
if( pGroup->pEnemyGroup->ubElitesInBattle < pGroup->pEnemyGroup->ubNumElites )
|
||||
{ //Add an elite troop
|
||||
pGroup->pEnemyGroup->ubElitesInBattle++;
|
||||
ubNumAvailable--;
|
||||
ubSlots--;
|
||||
ubNumElites++;
|
||||
}
|
||||
else if( pGroup->pEnemyGroup->ubTroopsInBattle < pGroup->pEnemyGroup->ubNumTroops )
|
||||
{ //Add a regular troop.
|
||||
pGroup->pEnemyGroup->ubTroopsInBattle++;
|
||||
ubNumAvailable--;
|
||||
ubSlots--;
|
||||
ubNumTroops++;
|
||||
}
|
||||
else if( pGroup->pEnemyGroup->ubAdminsInBattle < pGroup->pEnemyGroup->ubNumAdmins )
|
||||
{ //Add an admin troop
|
||||
pGroup->pEnemyGroup->ubAdminsInBattle++;
|
||||
ubNumAvailable--;
|
||||
ubSlots--;
|
||||
ubNumAdmins++;
|
||||
}
|
||||
else
|
||||
{
|
||||
AssertMsg( 0, "AddPossiblePendingEnemiesToBattle(): Logic Error -- by Kris" );
|
||||
}
|
||||
}
|
||||
if( ubNumAdmins || ubNumTroops || ubNumElites )
|
||||
{ //This group has contributed forces, then add them now, because different
|
||||
//groups appear on different sides of the map.
|
||||
UINT8 ubStrategicInsertionCode=0;
|
||||
//First, determine which entrypoint to use, based on the travel direction of the group.
|
||||
if( pGroup->ubPrevX && pGroup->ubPrevY )
|
||||
{
|
||||
if( pGroup->ubSectorX < pGroup->ubPrevX )
|
||||
ubStrategicInsertionCode = INSERTION_CODE_EAST;
|
||||
else if( pGroup->ubSectorX > pGroup->ubPrevX )
|
||||
ubStrategicInsertionCode = INSERTION_CODE_WEST;
|
||||
else if( pGroup->ubSectorY < pGroup->ubPrevY )
|
||||
ubStrategicInsertionCode = INSERTION_CODE_SOUTH;
|
||||
else if( pGroup->ubSectorY > pGroup->ubPrevY )
|
||||
ubStrategicInsertionCode = INSERTION_CODE_NORTH;
|
||||
}
|
||||
else if( pGroup->ubNextX && pGroup->ubNextY )
|
||||
{
|
||||
if( pGroup->ubSectorX < pGroup->ubNextX )
|
||||
ubStrategicInsertionCode = INSERTION_CODE_EAST;
|
||||
else if( pGroup->ubSectorX > pGroup->ubNextX )
|
||||
ubStrategicInsertionCode = INSERTION_CODE_WEST;
|
||||
else if( pGroup->ubSectorY < pGroup->ubNextY )
|
||||
ubStrategicInsertionCode = INSERTION_CODE_SOUTH;
|
||||
else if( pGroup->ubSectorY > pGroup->ubNextY )
|
||||
ubStrategicInsertionCode = INSERTION_CODE_NORTH;
|
||||
}
|
||||
//Add the number of each type of troop and place them in the appropriate positions
|
||||
AddEnemiesToBattle( pGroup, ubStrategicInsertionCode, ubNumAdmins, ubNumTroops, ubNumElites, FALSE );
|
||||
gfPendingEnemies = TRUE;
|
||||
}
|
||||
|
||||
// If there are still more to contribute, then move the remaining back to the sector they came from.
|
||||
if (ubNumAvailable)
|
||||
{
|
||||
pGroup->ubSectorX = pGroup->ubPrevX;
|
||||
pGroup->ubSectorY = pGroup->ubPrevY;
|
||||
}
|
||||
}
|
||||
pGroup = pGroup->next;
|
||||
ubNumGroupsInSector++;
|
||||
}
|
||||
|
||||
pGroupInSectorList = (GROUP**) MemAlloc( ubNumGroupsInSector * sizeof( GROUP*));
|
||||
for (ubNumGroupsInSector = 0, pGroup = gpGroupList; pGroup; pGroup = pGroup->next)
|
||||
{
|
||||
if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ )
|
||||
{
|
||||
pGroupInSectorList[ ubNumGroupsInSector++] = pGroup;
|
||||
}
|
||||
}
|
||||
|
||||
while( ubSlots && ubNumGroupsInSector )
|
||||
{
|
||||
UINT8 ubInsertionCode = 255;
|
||||
|
||||
ubGroupIndex = Random( ubNumGroupsInSector);
|
||||
pGroup = pGroupInSectorList[ ubGroupIndex];
|
||||
|
||||
ubNumAvailable = pGroup->ubGroupSize - pGroup->pEnemyGroup->ubElitesInBattle - pGroup->pEnemyGroup->ubTroopsInBattle - pGroup->pEnemyGroup->ubAdminsInBattle;
|
||||
if (!ubNumAvailable)
|
||||
{
|
||||
// Looks like we picked an empty group. Make a note of it
|
||||
pGroupInSectorList[ ubGroupIndex] = pGroupInSectorList[ --ubNumGroupsInSector ];
|
||||
continue;
|
||||
}
|
||||
|
||||
if( pGroup->ubPrevX && pGroup->ubPrevY )
|
||||
{
|
||||
if( pGroup->ubSectorX < pGroup->ubPrevX )
|
||||
ubInsertionCode = INSERTION_CODE_EAST;
|
||||
else if( pGroup->ubSectorX > pGroup->ubPrevX )
|
||||
ubInsertionCode = INSERTION_CODE_WEST;
|
||||
else if( pGroup->ubSectorY < pGroup->ubPrevY )
|
||||
ubInsertionCode = INSERTION_CODE_SOUTH;
|
||||
else if( pGroup->ubSectorY > pGroup->ubPrevY )
|
||||
ubInsertionCode = INSERTION_CODE_NORTH;
|
||||
else
|
||||
Assert(0);
|
||||
}
|
||||
else if( pGroup->ubNextX && pGroup->ubNextY )
|
||||
{
|
||||
if( pGroup->ubSectorX < pGroup->ubNextX )
|
||||
ubInsertionCode = INSERTION_CODE_EAST;
|
||||
else if( pGroup->ubSectorX > pGroup->ubNextX )
|
||||
ubInsertionCode = INSERTION_CODE_WEST;
|
||||
else if( pGroup->ubSectorY < pGroup->ubNextY )
|
||||
ubInsertionCode = INSERTION_CODE_SOUTH;
|
||||
else if( pGroup->ubSectorY > pGroup->ubNextY )
|
||||
ubInsertionCode = INSERTION_CODE_NORTH;
|
||||
else
|
||||
Assert(0);
|
||||
}
|
||||
else
|
||||
// The group has no movement orders. Where did it come from?
|
||||
Assert(0);
|
||||
|
||||
if( pGroup->pEnemyGroup->ubElitesInBattle < pGroup->pEnemyGroup->ubNumElites )
|
||||
{ //Add an elite troop
|
||||
pGroup->pEnemyGroup->ubElitesInBattle++;
|
||||
ubSlots--;
|
||||
AddEnemiesToBattle( pGroup, ubInsertionCode, 0, 0, 1, FALSE );
|
||||
}
|
||||
else if( pGroup->pEnemyGroup->ubTroopsInBattle < pGroup->pEnemyGroup->ubNumTroops )
|
||||
{ //Add a regular troop.
|
||||
pGroup->pEnemyGroup->ubTroopsInBattle++;
|
||||
ubSlots--;
|
||||
AddEnemiesToBattle( pGroup, ubInsertionCode, 0, 1, 0, FALSE );
|
||||
}
|
||||
else if( pGroup->pEnemyGroup->ubAdminsInBattle < pGroup->pEnemyGroup->ubNumAdmins )
|
||||
{ //Add an admin troop
|
||||
pGroup->pEnemyGroup->ubAdminsInBattle++;
|
||||
ubSlots--;
|
||||
AddEnemiesToBattle( pGroup, ubInsertionCode, 1, 0, 0, FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
AssertMsg( 0, "AddPossiblePendingEnemiesToBattle(): Logic Error -- by Kris" );
|
||||
}
|
||||
}
|
||||
|
||||
MemFree( pGroupInSectorList);
|
||||
|
||||
if( ubSlots )
|
||||
{ //After going through the process, we have finished with some free slots and no more enemies to add.
|
||||
//So, we can turn off the flag, as this check is no longer needed.
|
||||
gfPendingEnemies = FALSE;
|
||||
|
||||
if( gTacticalStatus.Team[ ENEMY_TEAM ].bAwareOfOpposition == TRUE )
|
||||
ubPredefinedInsertionCode = DoReinforcementAsPendingEnemy( gWorldSectorX, gWorldSectorY );
|
||||
else
|
||||
ubPredefinedInsertionCode = 255;
|
||||
|
||||
if( ubPredefinedInsertionCode != 255 )
|
||||
AddPossiblePendingEnemiesToBattle();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
#include "Reinforcement.h"
|
||||
#include "MilitiaSquads.h"
|
||||
|
||||
#define IS_ONLY_IN_CITIES ( gGameExternalOptions.gfAllowReinforcementsOnlyInCity ? TRUE: FALSE )
|
||||
|
||||
UINT8 gubReinforcementMinEnemyStaticGroupSize = 12;
|
||||
|
||||
void GetNumberOfEnemiesInFiveSectors( INT16 sSectorX, INT16 sSectorY, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites )
|
||||
@@ -248,6 +246,7 @@ UINT8 DoReinforcementAsPendingEnemy( INT16 sMapX, INT16 sMapY )
|
||||
UINT16 pusMoveDir[4][3];
|
||||
UINT8 ubDirNumber = 0, ubIndex;
|
||||
GROUP *pGroup;
|
||||
ENEMYGROUP *pEnemyGroup;
|
||||
SECTORINFO *pThisSector, *pSector;
|
||||
|
||||
if( !gGameExternalOptions.gfAllowReinforcements )
|
||||
@@ -261,6 +260,9 @@ UINT8 DoReinforcementAsPendingEnemy( INT16 sMapX, INT16 sMapY )
|
||||
GenerateDirectionInfos( sMapX, sMapY, &ubDirNumber, pusMoveDir,
|
||||
( GetTownIdForSector( sMapX, sMapY ) != BLANK_SECTOR ? TRUE : FALSE ), TRUE, IS_ONLY_IN_CITIES );
|
||||
|
||||
|
||||
#if 0
|
||||
// Combine this with the next part so that reinforcements from enemy groups can also come in from random sides
|
||||
for( ubIndex = 0; ubIndex < ubDirNumber; ubIndex++ )
|
||||
if( NumMobileEnemiesInSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) && GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) )
|
||||
{
|
||||
@@ -274,6 +276,7 @@ UINT8 DoReinforcementAsPendingEnemy( INT16 sMapX, INT16 sMapY )
|
||||
|
||||
return (UINT8)pusMoveDir[ ubIndex ][ 2 ];
|
||||
}
|
||||
#endif
|
||||
|
||||
if( NumEnemiesInFiveSectors( sMapX, sMapY ) - NumEnemiesInSector( sMapX, sMapY ) == 0 )
|
||||
{
|
||||
@@ -282,6 +285,51 @@ UINT8 DoReinforcementAsPendingEnemy( INT16 sMapX, INT16 sMapY )
|
||||
for(;;)
|
||||
{
|
||||
ubIndex = Random(ubDirNumber);
|
||||
if( NumMobileEnemiesInSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) && GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) )
|
||||
{
|
||||
UINT8 numElite;
|
||||
UINT8 numTroop;
|
||||
UINT8 numAdmin;
|
||||
|
||||
pGroup = GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) );
|
||||
pEnemyGroup = pGroup->pEnemyGroup;
|
||||
numElite = pEnemyGroup->ubNumElites - pEnemyGroup->ubElitesInBattle;
|
||||
numTroop = pEnemyGroup->ubNumTroops - pEnemyGroup->ubTroopsInBattle;
|
||||
numAdmin = pEnemyGroup->ubNumAdmins - pEnemyGroup->ubAdminsInBattle;
|
||||
|
||||
if (numElite + numTroop + numAdmin <= 1)
|
||||
{
|
||||
// The entire group has finally moved into the sector.
|
||||
pGroup->ubPrevX = pGroup->ubSectorX;
|
||||
pGroup->ubPrevY = pGroup->ubSectorY;
|
||||
|
||||
pGroup->ubSectorX = pGroup->ubNextX = (UINT8)sMapX;
|
||||
pGroup->ubSectorY = pGroup->ubNextY = (UINT8)sMapY;
|
||||
|
||||
return (UINT8)pusMoveDir[ ubIndex ][ 2 ];
|
||||
}
|
||||
|
||||
if (numAdmin + numTroop + numElite)
|
||||
{
|
||||
// Otherwise we move a soldier into the sector from the group
|
||||
if( numElite )
|
||||
{
|
||||
(pThisSector->ubNumElites)++;
|
||||
(pEnemyGroup->ubElitesInBattle)++;
|
||||
}else if( numTroop )
|
||||
{
|
||||
(pThisSector->ubNumTroops)++;
|
||||
(pEnemyGroup->ubTroopsInBattle)++;
|
||||
}else if( numAdmin )
|
||||
{
|
||||
(pThisSector->ubNumAdmins)++;
|
||||
(pEnemyGroup->ubAdminsInBattle)++;
|
||||
}
|
||||
|
||||
return (UINT8)pusMoveDir[ ubIndex ][ 2 ];
|
||||
}
|
||||
}
|
||||
|
||||
if( NumEnemiesInSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) > gubReinforcementMinEnemyStaticGroupSize )
|
||||
{
|
||||
pSector = &SectorInfo[ pusMoveDir[ ubIndex ][ 0 ] ];
|
||||
@@ -380,8 +428,13 @@ void AddPossiblePendingMilitiaToBattle()
|
||||
static UINT8 ubPredefinedInsertionCode = 255;
|
||||
static UINT8 ubPredefinedRank = 255;
|
||||
|
||||
if( !PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, 0 ) || !CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY )
|
||||
|| !NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) ) return;
|
||||
// if( !PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, 0 ) || !CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY )
|
||||
// || !NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) ) return;
|
||||
if( !PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, 0 )
|
||||
|| !(gTacticalStatus.uiFlags & WANT_MILITIA_REINFORCEMENTS)
|
||||
|| !NumEnemiesInSector( gWorldSectorX, gWorldSectorY )
|
||||
)
|
||||
return;
|
||||
//gGameExternalOptions.guiMaxMilitiaSquadSize - CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY );
|
||||
ubSlots = NumFreeMilitiaSlots();
|
||||
if( !ubSlots )
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef __REINFORCEMENT_H__
|
||||
#define __REINFORCEMENT_H__
|
||||
|
||||
|
||||
#define IS_ONLY_IN_CITIES ( gGameExternalOptions.gfAllowReinforcementsOnlyInCity ? TRUE: FALSE )
|
||||
|
||||
|
||||
//For Autoresolve (mostly)
|
||||
void GetNumberOfEnemiesInFiveSectors( INT16 sSectorX, INT16 sSectorY, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites );
|
||||
BOOLEAN IsGroupInARightSectorToReinforce( GROUP *pGroup, INT16 sSectorX, INT16 sSectorY );
|
||||
@@ -13,5 +17,6 @@ UINT8 NumEnemiesInFiveSectors( INT16 sMapX, INT16 sMapY );
|
||||
//For Tactical
|
||||
UINT8 DoReinforcementAsPendingEnemy( INT16 sMapX, INT16 sMapY );
|
||||
void AddPossiblePendingMilitiaToBattle();
|
||||
GROUP* GetEnemyGroupInSector( INT16 sMapX, INT16 sMapY );
|
||||
|
||||
#endif
|
||||
@@ -7433,13 +7433,11 @@ void GetHelpTextForItem( STR16 pzStr, OBJECTTYPE *pObject, SOLDIERTYPE *pSoldier
|
||||
}
|
||||
|
||||
/* 2007-05-27, Sergeant_Kolja: code temporarily added for tracking the
|
||||
6 Shuriken bug plus the
|
||||
SKI Tony inventory crash.
|
||||
Remove when fixed!
|
||||
*/
|
||||
# if defined( _DEBUG )
|
||||
if ( (pObject->ubGunAmmoType >= MAXITEMS) ||
|
||||
((usItem == 1053) && (pObject->ubGunAmmoType != 0 )) /* shuriken: 1053 */
|
||||
if ( (pObject->ubGunAmmoType >= MAXITEMS)
|
||||
)
|
||||
{
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_1, String( "corrupted pObject (%s) found in GetHelpTextForItem()", (usItem<MAXITEMS) ? Item[usItem].szItemName : "???" ));
|
||||
|
||||
+27
-27
@@ -766,33 +766,33 @@ void UnusedAPsToBreath(SOLDIERTYPE *pSold)
|
||||
// adjust for carried weight
|
||||
sBreathPerAP = sBreathPerAP * 100 / BreathPointAdjustmentForCarriedWeight( pSold );
|
||||
|
||||
if ( pSold->bTeam != CIV_TEAM && pSold->bTeam != gbPlayerNum)
|
||||
{
|
||||
switch( gGameOptions.ubDifficultyLevel )
|
||||
{
|
||||
case DIF_LEVEL_EASY:
|
||||
sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iEasyAPBonus)- sUnusedAPs) * sBreathPerAP;
|
||||
break;
|
||||
|
||||
case DIF_LEVEL_MEDIUM:
|
||||
sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iExperiencedAPBonus)-sUnusedAPs) * sBreathPerAP;
|
||||
break;
|
||||
|
||||
case DIF_LEVEL_HARD:
|
||||
sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iExpertAPBonus)- sUnusedAPs) * sBreathPerAP;
|
||||
break;
|
||||
|
||||
case DIF_LEVEL_INSANE:
|
||||
sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iInsaneAPBonus)- sUnusedAPs) * sBreathPerAP;
|
||||
break;
|
||||
|
||||
default:
|
||||
sBreathChange = (AP_MAXIMUM - sUnusedAPs) * sBreathPerAP;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iPlayerAPBonus)- sUnusedAPs) * sBreathPerAP;
|
||||
if ( pSold->bTeam != CIV_TEAM && pSold->bTeam != gbPlayerNum)
|
||||
{
|
||||
switch( gGameOptions.ubDifficultyLevel )
|
||||
{
|
||||
case DIF_LEVEL_EASY:
|
||||
sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iEasyAPBonus)- sUnusedAPs) * sBreathPerAP;
|
||||
break;
|
||||
|
||||
case DIF_LEVEL_MEDIUM:
|
||||
sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iExperiencedAPBonus)-sUnusedAPs) * sBreathPerAP;
|
||||
break;
|
||||
|
||||
case DIF_LEVEL_HARD:
|
||||
sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iExpertAPBonus)- sUnusedAPs) * sBreathPerAP;
|
||||
break;
|
||||
|
||||
case DIF_LEVEL_INSANE:
|
||||
sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iInsaneAPBonus)- sUnusedAPs) * sBreathPerAP;
|
||||
break;
|
||||
|
||||
default:
|
||||
sBreathChange = (AP_MAXIMUM - sUnusedAPs) * sBreathPerAP;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iPlayerAPBonus)- sUnusedAPs) * sBreathPerAP;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -5061,15 +5061,18 @@ BOOLEAN EVENT_InternalGetNewSoldierPath( SOLDIERTYPE *pSoldier, UINT16 sDestGrid
|
||||
}
|
||||
|
||||
// we can use the soldier's level here because we don't have pathing across levels right now...
|
||||
#if 0
|
||||
// Uhhmmmm, the name of this function has "NEWPath" in it.
|
||||
if (pSoldier->bPathStored)
|
||||
{
|
||||
fContinue = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
iDest = FindBestPath( pSoldier, sDestGridNo, pSoldier->bLevel, usMovementAnim, COPYROUTE, fFlags );
|
||||
fContinue = (iDest != 0);
|
||||
}
|
||||
// }
|
||||
|
||||
// Only if we can get a path here
|
||||
if ( fContinue )
|
||||
|
||||
Reference in New Issue
Block a user