New feature: bloodcat/zombie/bandit raids on player-controlled sectors

For more info, see http://thepit.ja-galaxy-forum.com/index.php?t=msg&th=23711&goto=353154&#msg_353154

Requires GameDir >= r2420

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8554 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2018-04-15 14:42:01 +00:00
parent 1ea69989ed
commit 80674249cc
52 changed files with 1628 additions and 479 deletions
+85
View File
@@ -27,6 +27,8 @@
#include "strategic.h"
#include "GameSettings.h"
#include "history.h"
#include "Town Militia.h" // added by Flugente
#include "Campaign.h" // added by Flugente
#endif
#include "Luaglobal.h"
@@ -52,6 +54,8 @@ UINT8 gubCambriaMedicalObjects;
extern INT8 NumMercsNear( UINT8 ubProfileID, UINT8 ubMaxDist );
extern SECTOR_EXT_DATA SectorExternalData[256][4];
// WANNE: No more used for the new airport code
//void DropOffItemsInMeduna( UINT8 ubOrderNum );
@@ -1097,6 +1101,87 @@ void HandleEarlyMorningEvents( void )
#endif
}
// Flugente: creature raids
void HandleRaidEventPlanning()
{
INT32 personnelgain[3];
// the raid order is bloodcats/zombies/bandits
for ( int raidtype = 0; raidtype < 3; ++raidtype )
{
personnelgain[raidtype] = 0;
if ( raidtype == 0 )
{
if ( !gGameExternalOptions.gRaid_Bloodcats )
continue;
// if the lair has been cleared, way less growth
if ( CheckFact(FACT_BLOODCAT_LAIR_CLEANED, NO_PROFILE) )
personnelgain[raidtype] += gGameExternalOptions.gRaidReplenish_BaseValue;
else
personnelgain[raidtype] += 3 * gGameExternalOptions.gRaidReplenish_BaseValue;
}
else if ( raidtype == 1 )
{
if ( !gGameExternalOptions.gRaid_Zombies || !gGameSettings.fOptions[TOPTION_ZOMBIES] )
continue;
// zombies grow very fast
personnelgain[raidtype] += 15 * gGameExternalOptions.gRaidReplenish_BaseValue;
}
else if ( raidtype == 2 )
{
if ( !gGameExternalOptions.gRaid_Bandits )
continue;
// bandit growth depends on progress
personnelgain[raidtype] += gGameExternalOptions.gRaidReplenish_BaseValue * (150 + HighestPlayerProgressPercentage()) / 100;
}
std::vector<INT16> attacksectors;
for ( INT16 sector = 0; sector <= 255; ++sector )
{
if ( !StrategicMap[SECTOR_INFO_TO_STRATEGIC_INDEX( sector )].fEnemyControlled )
{
if ( ( SectorExternalData[sector][0].usSectorFlagMask & (SECTORFLAG_RAIDPOSSIBLE_BLOODCAT << raidtype ) ) )
{
attacksectors.push_back( sector );
}
}
}
if ( attacksectors.empty() )
continue;
int numattacks = gGameExternalOptions.gRaid_MaxAttackPerNight_Bandits;
if ( raidtype == 0 )
numattacks = gGameExternalOptions.gRaid_MaxAttackPerNight_Bloodcats;
else if ( raidtype == 1 )
numattacks = gGameExternalOptions.gRaid_MaxAttackPerNight_Zombies;
for ( int attack = 0; attack < numattacks; ++attack )
{
UINT32 sector = attacksectors[Random(attacksectors.size())];
// attack random sector
if ( raidtype == 0 )
// bloodcats only attack at night (it is 7:00 now)
//AddStrategicEvent( EVENT_BLOODCAT_ATTACK, GetWorldTotalMin() + 14 * 60 + Random(10 * 60), sector );
AddStrategicEvent( EVENT_BLOODCAT_ATTACK, GetWorldTotalMin() + 12 * 60 + 30, sector );
else
// other attacks can happen all the time
//AddStrategicEvent( EVENT_BLOODCAT_ATTACK + raidtype, GetWorldTotalMin() + Random( 24 * 60 ), sector );
AddStrategicEvent( EVENT_BLOODCAT_ATTACK + raidtype, GetWorldTotalMin() + 13 * 60 + 15, sector );
}
}
// every day we refill our available personnel
// this also means that at day 1 we have no personnel for raids, forces have to slowly be built up
AddRaidPersonnel( personnelgain[0], personnelgain[1], personnelgain[2] );
}
void MakeCivGroupHostileOnNextSectorEntrance( UINT8 ubCivGroup )
{
// if it's the rebels that will become hostile, reduce town loyalties NOW, not later