mirror of
https://github.com/1dot13/source.git
synced 2026-08-26 14:30:26 +02:00
HandlePrison:
- more precise calculation of prisoner to guard ratio - improved calculation of random number of prisoners escaping (allow single prisoner/max prisoners to escape when not guarded) - check that someone actually escaped before showing riot message - limit ubNumTroops to 255 (like in other places) as 512 makes no sense for UINT8 value git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9390 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+19
-12
@@ -8746,24 +8746,31 @@ void HandlePrison( INT16 sMapX, INT16 sMapY, INT8 bZ )
|
|||||||
{
|
{
|
||||||
FLOAT prisonertoguardratio = 1.0f;
|
FLOAT prisonertoguardratio = 1.0f;
|
||||||
if ( prisonguardvalue )
|
if ( prisonguardvalue )
|
||||||
prisonertoguardratio = (FLOAT)(prisonerriotvalue / prisonguardvalue);
|
prisonertoguardratio = (FLOAT)prisonerriotvalue / (FLOAT)prisonguardvalue;
|
||||||
|
|
||||||
// in a riot, prisoners escape and are added to the sector as enemies. Not all might escape - the worse the prisoner/guard ratio, the more escape
|
// in a riot, prisoners escape and are added to the sector as enemies. Not all might escape - the worse the prisoner/guard ratio, the more escape
|
||||||
INT16 escapedprisoners[PRISONER_MAX] = {0};
|
INT16 escapedprisoners[PRISONER_MAX] = {0};
|
||||||
for (int i = PRISONER_ADMIN; i < PRISONER_MAX; ++i )
|
INT16 sTotalEscapedPrisoners = 0;
|
||||||
escapedprisoners[i] = min( Random( aPrisoners[i] * prisonertoguardratio ), aPrisoners[i] );
|
for (int i = PRISONER_ADMIN; i < PRISONER_MAX; ++i)
|
||||||
|
{
|
||||||
|
escapedprisoners[i] = min(Random(1 + aPrisoners[i] * prisonertoguardratio), aPrisoners[i]);
|
||||||
|
sTotalEscapedPrisoners += escapedprisoners[i];
|
||||||
|
}
|
||||||
|
|
||||||
// add enemies (PRISONER_CIVILIAN just flee)
|
if (sTotalEscapedPrisoners > 0)
|
||||||
pSectorInfo->ubNumTroops = min( 512, pSectorInfo->ubNumTroops + escapedprisoners[PRISONER_REGULAR] );
|
{
|
||||||
pSectorInfo->ubNumElites = min( 512, pSectorInfo->ubNumElites + escapedprisoners[PRISONER_ELITE] + escapedprisoners[PRISONER_OFFICER] + escapedprisoners[PRISONER_GENERAL] );
|
// add enemies (PRISONER_CIVILIAN just flee)
|
||||||
pSectorInfo->ubNumAdmins = min( 512, pSectorInfo->ubNumAdmins + escapedprisoners[PRISONER_ADMIN] );
|
pSectorInfo->ubNumTroops = min(255, pSectorInfo->ubNumTroops + escapedprisoners[PRISONER_REGULAR]);
|
||||||
|
pSectorInfo->ubNumElites = min(255, pSectorInfo->ubNumElites + escapedprisoners[PRISONER_ELITE] + escapedprisoners[PRISONER_OFFICER] + escapedprisoners[PRISONER_GENERAL]);
|
||||||
|
pSectorInfo->ubNumAdmins = min(255, pSectorInfo->ubNumAdmins + escapedprisoners[PRISONER_ADMIN]);
|
||||||
|
|
||||||
// reduce prisoner count!
|
// reduce prisoner count!
|
||||||
// we have to change the sign
|
// we have to change the sign
|
||||||
for ( int i = PRISONER_ADMIN; i < PRISONER_MAX; ++i )
|
for (int i = PRISONER_ADMIN; i < PRISONER_MAX; ++i)
|
||||||
escapedprisoners[i] = -escapedprisoners[i];
|
escapedprisoners[i] = -escapedprisoners[i];
|
||||||
|
|
||||||
ChangeNumberOfPrisoners( pSectorInfo, escapedprisoners );
|
ChangeNumberOfPrisoners(pSectorInfo, escapedprisoners);
|
||||||
|
}
|
||||||
|
|
||||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_RIOT], wSectorName );
|
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_RIOT], wSectorName );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user