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
@@ -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 );