Brief: //dnl ch68

- Magically appeared reinforcements for enemy and militia just turn after they are called from now could be delayed and randomized.
Details:
- Practically all enemy reinforcement which can populate available slots was always appeared next turn after they are called so now we have game settings under "Strategic Gameplay Settings" for fine tunning enemy and militia reinforce entry:
  MIN_DELAY_ENEMY_REINFORCEMENTS enemy reinforcement will arrive minimum this number of turns after they are called, if 0 then is disabled.
  RND_DELAY_ENEMY_REINFORCEMENTS additional random delay added to minimum when reinforcements will arrive after they are called.
  MIN_ENTER_ENEMY_REINFORCEMENTS minimum enemy units which will enter after above delay is over.
  RND_ENTER_ENEMY_REINFORCEMENTS additional random enemy units to appear after passing delay.
  MIN_DELAY_MILITIA_REINFORCEMENTS enemy reinforcement will arrive minimum this number of turns after they are called, if 0 then is disabled.
  RND_DELAY_MILITIA_REINFORCEMENTS additional random delay added to minimum when reinforcements will arrive after they are called.
  MIN_ENTER_MILITIA_REINFORCEMENTS minimum enemy units which will enter after above delay is over.
  RND_ENTER_MILITIA_REINFORCEMENTS additional random enemy units to appear after passing delay.
- After first delay ends any other reinforcement appeared more frequently or if already arrive (but no free slot), they will pop up soon after slot is free.
- Add option NO_REMOVE_RANDOM_SECTOR_ITEMS under "Strategic Gameplay Settings" to prevent permanent random removal of your sector items.
- Add missing function DisplaySectorItemsInfo.


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6386 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Kriplo
2013-09-10 20:49:49 +00:00
parent f65bc9d649
commit f5ac5be03f
13 changed files with 148 additions and 20 deletions
+13 -1
View File
@@ -2015,13 +2015,25 @@ void LoadGameExternalOptions()
gGameExternalOptions.fUseXMLSquadNames = iniReader.ReadBoolean("Strategic Assignment Settings", "USE_XML_SQUADNAMES", FALSE);
//dnl ch68 090913 Reinforcements minimum+random turn delay and minimum+random units enter for enemy and militia after they have been called
gGameExternalOptions.sMinDelayEnemyReinforcements = iniReader.ReadInteger("Strategic Gameplay Settings", "MIN_DELAY_ENEMY_REINFORCEMENTS", 7, 0, 100);
gGameExternalOptions.sRndDelayEnemyReinforcements = iniReader.ReadInteger("Strategic Gameplay Settings", "RND_DELAY_ENEMY_REINFORCEMENTS", 8, 0, 100);
gGameExternalOptions.sMinEnterEnemyReinforcements = iniReader.ReadInteger("Strategic Gameplay Settings", "MIN_ENTER_ENEMY_REINFORCEMENTS", 6, 1, 64);
gGameExternalOptions.sRndEnterEnemyReinforcements = iniReader.ReadInteger("Strategic Gameplay Settings", "RND_ENTER_ENEMY_REINFORCEMENTS", 6, 1, 64);
gGameExternalOptions.sMinDelayMilitiaReinforcements = iniReader.ReadInteger("Strategic Gameplay Settings", "MIN_DELAY_MILITIA_REINFORCEMENTS", 10, 0, 100);
gGameExternalOptions.sRndDelayMilitiaReinforcements = iniReader.ReadInteger("Strategic Gameplay Settings", "RND_DELAY_MILITIA_REINFORCEMENTS", 10, 0, 100);
gGameExternalOptions.sMinEnterMilitiaReinforcements = iniReader.ReadInteger("Strategic Gameplay Settings", "MIN_ENTER_MILITIA_REINFORCEMENTS", 6, 1, 64);
gGameExternalOptions.sRndEnterMilitiaReinforcements = iniReader.ReadInteger("Strategic Gameplay Settings", "RND_ENTER_MILITIA_REINFORCEMENTS", 4, 1, 64);
//dnl ch68 090913 Don't allow permanent items removal from sector
gGameExternalOptions.fNoRemoveRandomSectorItems = iniReader.ReadBoolean("Strategic GamePlay Settings", "NO_REMOVE_RANDOM_SECTOR_ITEMS", true, false);
// WANNE: This is just a debug setting. Only in debug version we set that property to TRUE.
// In Release version this should always be set to FALSE
// dnl ch51 081009 JA2 Debug Settings
#ifdef _DEBUG
gGameExternalOptions.fEnableInventoryPoolQ = TRUE;
#else
gGameExternalOptions.fEnableInventoryPoolQ = FALSE;
gGameExternalOptions.fEnableInventoryPoolQ = FALSE;
#endif
////////// CLOCK SETTINGS //////////
+13 -1
View File
@@ -1146,7 +1146,7 @@ typedef struct
BOOLEAN fSaveGameSlot;
//dnl ch51 081009 JA2 Debug Settings
BOOLEAN fEnableInventoryPoolQ;
BOOLEAN fEnableInventoryPoolQ;
//legion by Jazz
//BOOLEAN fShowTacticalFaceGear; //legion 2
@@ -1280,6 +1280,18 @@ typedef struct
// Flugente: externalised squad names
BOOLEAN fUseXMLSquadNames;
//dnl ch68 090913 Reinforcements Setttings
UINT16 sMinDelayEnemyReinforcements;
UINT16 sRndDelayEnemyReinforcements;
UINT16 sMinEnterEnemyReinforcements;
UINT16 sRndEnterEnemyReinforcements;
UINT16 sMinDelayMilitiaReinforcements;
UINT16 sRndDelayMilitiaReinforcements;
UINT16 sMinEnterMilitiaReinforcements;
UINT16 sRndEnterMilitiaReinforcements;
BOOLEAN fNoRemoveRandomSectorItems;//dnl ch68 090913
} GAME_EXTERNAL_OPTIONS;
typedef struct
+5
View File
@@ -5963,6 +5963,11 @@ BOOLEAN LoadSavedGame( int ubSavedGameID )
if(gGameExternalOptions.fEnableInventoryPoolQ)//dnl ch51 081009
if(!LoadInventoryPoolQ(ubSavedGameID))
return(FALSE);
//dnl ch68 100913 // basic guess when reinforcement should arrive after load game as reinforcement globals are not saved
if(guiReinforceTurn)
guiReinforceTurn = guiTurnCnt + gGameExternalOptions.sMinDelayEnemyReinforcements/2 + Random(gGameExternalOptions.sRndDelayEnemyReinforcements+1);
if(guiMilitiaReinforceTurn)
guiMilitiaReinforceTurn = guiTurnCnt + gGameExternalOptions.sMinDelayMilitiaReinforcements/2 + Random(gGameExternalOptions.sRndDelayMilitiaReinforcements+1);
//now change the savegame format so that temp files are saved and loaded correctly
guiCurrentSaveGameVersion = SAVE_GAME_VERSION;
+1 -1
View File
@@ -2921,4 +2921,4 @@ BOOLEAN LoadDataSaveFromLoadGameFile( HWFILE hFile )
}
return( TRUE );
}
}
+1 -1
View File
@@ -92,4 +92,4 @@ void InitializeRandom()
guiPreRandomIndex = 0;
}
#endif
#endif
@@ -3450,6 +3450,9 @@ BOOLEAN CanPlayerUseSectorInventory( SOLDIERTYPE *pSelectedSoldier )
{
INT16 sSectorX, sSectorY, sSectorZ;
if(gGameExternalOptions.fEnableInventoryPoolQ)//dnl ch51 200813
return(TRUE);
//Get the sector that has a battle
BOOLEAN fInCombat = GetCurrentBattleSectorXYZAndReturnTRUEIfThereIsABattle( &sSectorX, &sSectorY, &sSectorZ );
@@ -3723,6 +3726,26 @@ BOOLEAN CopySectorInventoryToInventoryPoolQs(UINT8 idx)
fMapPanelDirty = TRUE;
return(TRUE);
}
BOOLEAN DisplaySectorItemsInfo(void)//dnl ch51 090913
{
INT32 iCounter, iItemCount, iItemTraps;
WORLDITEM *pWorldItem;
iItemCount = 0;
iItemTraps = 0;
for(iCounter=0; (UINT32)iCounter<guiNumWorldItems; iCounter++)
{
pWorldItem = &gWorldItems[iCounter];
if(pWorldItem->bVisible<=0 && pWorldItem->fExists && !(pWorldItem->object.usItem==NOTHING || pWorldItem->object.usItem==SWITCH || pWorldItem->object.usItem==ACTION_ITEM || pWorldItem->object.usItem==OWNERSHIP || pWorldItem->object.usItem==SYRINGE_3 || pWorldItem->object.usItem==SYRINGE_4 || pWorldItem->object.usItem==SYRINGE_5))
iItemCount++;
if(/*pWorldItem->object[0]->data.bTrap > 0 && (pWorldItem->usFlags & WORLD_ITEM_ARMED_BOMB) && */pWorldItem->object[0]->data.misc.usBombItem)
iItemTraps++;
// SendFmtMsg("Item%.4d:%4d %d %.4X %.4X %.2X %.2X %.2X %d", iCounter, pWorldItem->bVisible, pWorldItem->fExists, pWorldItem->sGridNo, pWorldItem->usFlags, pWorldItem->object[0]->data.bTrap, pWorldItem->object[0]->data.fUsed, pWorldItem->object[0]->data.misc.usBombItem, pWorldItem->object.usItem);
}
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%d unseen items and %d boobytraps left.", iItemCount, iItemTraps);
return(TRUE);
}
//dnl ch51 081009 finish
void DeleteAllItemsInInventoryPool()
+35
View File
@@ -73,6 +73,7 @@ std::vector<SECTORINFO> SectorInfo (256);
UNDERGROUND_SECTORINFO *gpUndergroundSectorInfoHead = NULL;
extern UNDERGROUND_SECTORINFO* gpUndergroundSectorInfoTail;
BOOLEAN gfPendingEnemies = FALSE;
UINT32 guiTurnCnt = 0, guiReinforceTurn = 0, guiArrived = 0;//dnl ch68 080913
extern void BuildUndergroundSectorInfoList();
extern void EndCreatureQuest();
@@ -1390,6 +1391,40 @@ void AddPossiblePendingEnemiesToBattle()
|| !NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) ) return;
ubSlots = NumFreeEnemySlots();
if(gGameExternalOptions.sMinDelayEnemyReinforcements)//dnl ch68 080913
{
if(gTacticalStatus.Team[ENEMY_TEAM].bAwareOfOpposition == TRUE)
{
if(guiReinforceTurn == 0)
{
guiReinforceTurn = guiTurnCnt + gGameExternalOptions.sMinDelayEnemyReinforcements + Random(gGameExternalOptions.sRndDelayEnemyReinforcements+1);// first possible reinforcement
ubSlots = 0;
}
else if(guiTurnCnt >= guiReinforceTurn)
{
guiReinforceTurn = guiTurnCnt + gGameExternalOptions.sMinDelayEnemyReinforcements/3 + Random(gGameExternalOptions.sRndDelayEnemyReinforcements+1);// any other reinforcement should appear more frequently
ubNumAvailable = gGameExternalOptions.sMinEnterEnemyReinforcements + Random(gGameExternalOptions.sRndEnterEnemyReinforcements+1);// total allowed units to enter per reinforce turn
//SendFmtMsg("Enemy reinforcements: ubSlots=%d ubNumAvailable=%d", ubSlots, ubNumAvailable);
if(ubSlots > ubNumAvailable)
ubSlots = ubNumAvailable;
guiArrived += (ubNumAvailable - ubSlots);
}
else
{
if(guiArrived > 0)
{
if(ubSlots > guiArrived)
ubSlots = guiArrived;
guiArrived -= ubSlots;
}
else
ubSlots = 0;
}
}
else
guiReinforceTurn = guiArrived = 0;
//SendFmtMsg("Enemy reinforcements: guiTurnCnt=%d guiReinforceTurn=%d guiArrived=%d", guiTurnCnt, guiReinforceTurn, guiArrived);
}
if( !ubSlots )
{ //no available slots to add enemies to. Try again later...
return;
+3 -1
View File
@@ -62,4 +62,6 @@ extern INT32 gsGridNoForMapEdgePointInfo;
BOOLEAN CheckPendingEnemies();
#endif
extern UINT32 guiTurnCnt, guiReinforceTurn, guiMilitiaReinforceTurn;//dnl ch68 080913
#endif
+35
View File
@@ -29,6 +29,7 @@
#include "MilitiaSquads.h"
UINT8 gubReinforcementMinEnemyStaticGroupSize = 12;
UINT32 guiMilitiaReinforceTurn = 0, guiMilitiaArrived = 0;//dnl ch68 090913
void GetNumberOfEnemiesInFiveSectors( INT16 sSectorX, INT16 sSectorY, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites )
{
@@ -399,6 +400,40 @@ void AddPossiblePendingMilitiaToBattle()
return;
//gGameExternalOptions.guiMaxMilitiaSquadSize - CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY );
ubSlots = NumFreeMilitiaSlots();
if(gGameExternalOptions.sMinDelayMilitiaReinforcements)//dnl ch68 090913
{
if(gTacticalStatus.Team[MILITIA_TEAM].bAwareOfOpposition == TRUE)
{
if(guiMilitiaReinforceTurn == 0)
{
guiMilitiaReinforceTurn = guiTurnCnt + gGameExternalOptions.sMinDelayMilitiaReinforcements + Random(gGameExternalOptions.sRndDelayMilitiaReinforcements+1);// first possible reinforcement
ubSlots = 0;
}
else if(guiTurnCnt >= guiMilitiaReinforceTurn)
{
guiMilitiaReinforceTurn = guiTurnCnt + gGameExternalOptions.sMinDelayMilitiaReinforcements/3 + Random(gGameExternalOptions.sRndDelayMilitiaReinforcements+1);// any other reinforcement should appear more frequently
UINT8 ubNumAvailable = gGameExternalOptions.sMinEnterMilitiaReinforcements + Random(gGameExternalOptions.sRndEnterMilitiaReinforcements+1);// total allowed units to enter per reinforce turn
//SendFmtMsg("Militia reinforcements: ubSlots=%d ubNumAvailable=%d", ubSlots, ubNumAvailable);
if(ubSlots > ubNumAvailable)
ubSlots = ubNumAvailable;
guiMilitiaArrived += (ubNumAvailable - ubSlots);
}
else
{
if(guiMilitiaArrived > 0)
{
if(ubSlots > guiMilitiaArrived)
ubSlots = guiMilitiaArrived;
guiMilitiaArrived -= ubSlots;
}
else
ubSlots = 0;
}
}
else
guiMilitiaReinforceTurn = guiMilitiaArrived = 0;
//SendFmtMsg("Militia reinforcements: guiTurnCnt=%d guiReinforceTurn=%d guiArrived=%d", guiTurnCnt, guiMilitiaReinforceTurn, guiMilitiaArrived);
}
if( !ubSlots )
{ //no available slots to add militia to. Try again later...
return;
+2
View File
@@ -1115,6 +1115,8 @@ void RemoveRandomItemsInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ,
UINT32 uiNewTotal = 0;
CHAR16 wSectorName[ 128 ];
if(gGameExternalOptions.fNoRemoveRandomSectorItems)//dnl ch68 090913
return;
// stealing should fail anyway 'cause there shouldn't be a temp file for unvisited sectors, but let's check anyway
Assert( GetSectorFlagStatus( sSectorX, sSectorY, ( UINT8 ) sSectorZ, SF_ALREADY_VISITED ) == TRUE );
+1
View File
@@ -175,6 +175,7 @@ void HandleTacticalEndTurn( )
// decay AI warning values from corpses
DecayRottingCorpseAIWarnings();
((gTacticalStatus.Team[ENEMY_TEAM].bTeamActive || gTacticalStatus.Team[MILITIA_TEAM].bTeamActive) ? (guiTurnCnt++) : (guiTurnCnt = 0));//dnl ch68 090913
//Check for enemy pooling (add enemies if there happens to be more than the max in the
//current battle. If one or more slots have freed up, we can add them now.
AddPossiblePendingEnemiesToBattle();
+1
View File
@@ -325,6 +325,7 @@ void EndTurn( UINT8 ubNextTeam )
}
else
{
guiTurnCnt++;//dnl ch68 080913
// Flugente: I'm not really sure why we check here for gGameExternalOptions.ubReinforcementsFirstTurnFreeze, shouldn't that be a check for ALLOW_REINFORCEMENTS?
// as this inhibits reinforcements during turnbased-mode, I'll check for that instead
// HEADROCK HAM 3.2: Experimental fix to force reinforcements enter battle with 0 APs.
+15 -15
View File
@@ -3625,21 +3625,21 @@ LEVELNODE * FindShadow( INT32 sGridNo, UINT16 usStructIndex )
// WANNE: Improved v1.13 version to find the shadow tile. (by Realist)
// This should fix the bug, finding and swapping shadows when swapping structures
// e.g: When curring a fence tile, the shadow tile was not swapped. Now it should be fixed.
LEVELNODE* FindShadow(INT32 sGridNo, UINT16 usStructIndex)
{
TILE_ELEMENT const * const te = &gTileDatabase[usStructIndex];
if (te->uiFlags & HAS_SHADOW_BUDDY && te->sBuddyNum != -1)
{
LEVELNODE* pLevelNode;
for (pLevelNode = gpWorldLevelData[sGridNo].pShadowHead; pLevelNode != NULL; pLevelNode = pLevelNode->pNext)
{
if (pLevelNode->usIndex == te->sBuddyNum)
{
return pLevelNode;
}
}
}
return NULL;
LEVELNODE* FindShadow(INT32 sGridNo, UINT16 usStructIndex)
{
TILE_ELEMENT const * const te = &gTileDatabase[usStructIndex];
if (te->uiFlags & HAS_SHADOW_BUDDY && te->sBuddyNum != -1)
{
LEVELNODE* pLevelNode;
for (pLevelNode = gpWorldLevelData[sGridNo].pShadowHead; pLevelNode != NULL; pLevelNode = pLevelNode->pNext)
{
if (pLevelNode->usIndex == te->sBuddyNum)
{
return pLevelNode;
}
}
}
return NULL;
}