New feature: localized weather adds more weather types, different weather can happen in different sectors at the same time.

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

Requires GameDir >= r2325

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8253 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2016-06-18 20:57:03 +00:00
parent facadda6e8
commit 503523a9fa
40 changed files with 1059 additions and 522 deletions
+35 -2
View File
@@ -20,6 +20,7 @@
#include "DynamicDialogue.h"
#include <math.h>
#include "Drugs And Alcohol.h" // for DoesMercHaveDisability( ... )
#include "environment.h"
//GLOBALS
DISEASE Disease[NUM_DISEASES];
@@ -503,9 +504,11 @@ UINT16 GetSectorPopulation( INT16 sX, INT16 sY, BOOLEAN fWithMilitary )
}
// colour for a sector on the map
INT32 GetMapColour( INT16 sX, INT16 sY, BOOLEAN aDiseaseOn )
// aType = 0: disease
// aType = 1: weather
INT32 GetMapColour( INT16 sX, INT16 sY, UINT8 aType )
{
if ( aDiseaseOn )
if ( aType == 0 )
{
UINT16 population = GetSectorPopulation( sX, sY );
@@ -541,6 +544,36 @@ INT32 GetMapColour( INT16 sX, INT16 sY, BOOLEAN aDiseaseOn )
}
}
}
else if ( aType == 1 )
{
UINT8 sector = SECTOR( sX, sY );
SECTORINFO *pSectorInfo = &(SectorInfo[sector]);
// display sector information only if we know about infection there
if ( pSectorInfo )
{
switch ( pSectorInfo->usWeather )
{
case WEATHER_FORECAST_RAIN:
return MAP_SHADE_LT_CYAN;
break;
case WEATHER_FORECAST_THUNDERSHOWERS:
return MAP_SHADE_LT_BLUE;
break;
case WEATHER_FORECAST_SANDSTORM:
return MAP_SHADE_ORANGE;
break;
case WEATHER_FORECAST_SNOW:
return MAP_SHADE_LT_GREY;
break;
case WEATHER_FORECAST_NORMAL:
default:
return MAP_SHADE_BLACK;
break;
}
}
}
return MAP_SHADE_DK_GREY;
}
+3 -1
View File
@@ -138,7 +138,9 @@ INT16 GetAdjacentSector( UINT8 sector, UINT8 spdir );
UINT16 GetSectorPopulation( INT16 sX, INT16 sY, BOOLEAN fWithMilitary = TRUE );
// colour for a sector on the map
INT32 GetMapColour( INT16 sX, INT16 sY, BOOLEAN aDiseaseOn );
// aType = 0: disease
// aType = 1: weather
INT32 GetMapColour( INT16 sX, INT16 sY, UINT8 aType );
// handle infection redistribution if people move from A to B (set sXB and sYB to negative values to simply remove infected people in A)
void PopulationMove( INT16 sXA, INT16 sYA, INT16 sXB, INT16 sYB, UINT16 usAmount );
+3
View File
@@ -505,6 +505,9 @@ typedef struct
UINT16 usCivilianPopulation; // total amount of civilians that are supposed to be in this sector. This does not have to be the number of civilians in tactical
UINT8 rainchance; // chance that it rains in this sector
UINT8 sandstormchance; // chance that a sandstorm happens in this sector
UINT8 snowchance; // chance that it snows in this sector
} SECTOR_EXT_DATA;
// get dirt increase for object with attachments, fConsiderAmmo: with ammo
+6 -1
View File
@@ -6154,7 +6154,12 @@ INT8 FireBulletGivenTargetTrapOnly( SOLDIERTYPE* pThrower, OBJECTTYPE* pObj, INT
int maxJamChance = 50; // Externalize this?
int reliability = GetReliability( pObj );
int condition = (*pObj)[0]->data.gun.bGunStatus;
int invertedBaseJamChance = condition + (reliability * 2) - gGameExternalOptions.ubWeaponReliabilityReductionPerRainIntensity * 1;
int weatherpenalty = 0;
if ( pThrower && !pThrower->bSectorZ )
weatherpenalty = gGameExternalOptions.ubWeaponReliabilityReduction[SectorInfo[SECTOR( pThrower->sSectorX, pThrower->sSectorY )].usWeather];
int invertedBaseJamChance = condition + (reliability * 2) - weatherpenalty;
// Flugente: If overheating is allowed, a gun will be prone to more overheating if its temperature is high
if ( gGameExternalOptions.fWeaponOverheating )
+7 -14
View File
@@ -1461,10 +1461,6 @@ void UnusedAPsToBreath( SOLDIERTYPE * pSoldier )
}
//rain
extern INT8 gbCurrentRainIntensity;
//end rain
INT16 GetBreathPerAP( SOLDIERTYPE *pSoldier, UINT16 usAnimState )
{
INT16 sBreathPerAP = 0;
@@ -1540,21 +1536,18 @@ INT16 GetBreathPerAP( SOLDIERTYPE *pSoldier, UINT16 usAnimState )
//rain
// Reduce breath gain on 25%/rain intensity
// Lalien: only for soldiers that are in loaded sector,
if ( gfWorldLoaded && pSoldier->bInSector)
if ( gfWorldLoaded && pSoldier->bInSector && !pSoldier->bSectorZ )
{
if( sBreathPerAP < 0 && ( pSoldier->pathing.bLevel || !FindStructure( pSoldier->sGridNo, STRUCTURE_ROOF ) ) && pSoldier->bBreath > 1)
{
FLOAT weatherpenalty = gGameExternalOptions.dBreathGainReduction[SectorInfo[SECTOR( pSoldier->sSectorX, pSoldier->sSectorY )].usWeather];
// Added a feature to reduce rain effect on regaining breath with Ranger trait - SANDRO
if ( HAS_SKILL_TRAIT( pSoldier, SURVIVAL_NT ) && (gGameOptions.fNewTraitSystem) )
{
INT16 sBreathGainPenalty = 0;
sBreathGainPenalty = (INT16)((gGameExternalOptions.ubBreathGainReductionPerRainIntensity * (100 - gSkillTraitValues.ubSVWeatherPenaltiesReduction * NUM_SKILL_TRAITS( pSoldier, SURVIVAL_NT ))) / 100);
sBreathGainPenalty = min( max( 0, sBreathGainPenalty ), 100); // keep it 0-100%
sBreathPerAP -= (INT16)( sBreathPerAP * gbCurrentRainIntensity * sBreathGainPenalty /100 );
}
else
sBreathPerAP -= (INT16)( sBreathPerAP * gbCurrentRainIntensity * gGameExternalOptions.ubBreathGainReductionPerRainIntensity / 100 );
FLOAT appliedpenalty = 1.0f;
if ( HAS_SKILL_TRAIT( pSoldier, SURVIVAL_NT ) && gGameOptions.fNewTraitSystem )
appliedpenalty = min( 1.0f, max( 0.0f, appliedpenalty - gSkillTraitValues.dSVWeatherPenaltiesReduction * NUM_SKILL_TRAITS( pSoldier, SURVIVAL_NT ) ) );
sBreathPerAP -= (INT16)(sBreathPerAP * weatherpenalty * appliedpenalty);
}
}
//end rain
+147 -61
View File
@@ -107,7 +107,7 @@ TRainDrop *pRainDrops = 0;
UINT32 guiCurrMaxAmountOfRainDrops = 0;
UINT32 guiCurrAmountOfDeadRainDrops = 0;
INT8 gbCurrentRainIntensity = 0;
UINT8 gbCurrentWeather = 0;
FLOAT fpCurrDropAngleOfFalling = 0;
FLOAT fpCurrDropLength = 0;
@@ -123,7 +123,6 @@ FLOAT fpMinDropSpeed = 0;
extern UINT32 guiCurrentScreen;
//extern BOOLEAN gfAllowRain;
extern INT16 gsVIEWPORT_WINDOW_END_Y;
extern INT16 gsVIEWPORT_WINDOW_START_Y;
@@ -134,26 +133,17 @@ extern UINT32 guiNumVideoOverlays;
extern MercPopUpBox *gPopUpTextBox;
INT8 GetRainIntensityFromEnvWeather()
{
INT8 bRes = 0;
// Debug!!!
// guiEnvWeather |= WEATHER_FORECAST_THUNDERSHOWERS;
if( guiEnvWeather & WEATHER_FORECAST_SHOWERS ) bRes += 1;
if( guiEnvWeather & WEATHER_FORECAST_THUNDERSHOWERS ) bRes += 2;
return bRes;
}
BOOLEAN IsItAllowedToRenderRain()
{
if( !gGameExternalOptions.gfAllowRain )return FALSE;
if ( !(gGameExternalOptions.gfAllowRain || gGameExternalOptions.gfAllowSandStorms || gGameExternalOptions.gfAllowSnow) )
return FALSE;
if( !( guiEnvWeather & (WEATHER_FORECAST_THUNDERSHOWERS | WEATHER_FORECAST_SHOWERS) ) )return FALSE;
if ( !(GetWeatherInCurrentSector( ) == WEATHER_FORECAST_RAIN || GetWeatherInCurrentSector( ) == WEATHER_FORECAST_THUNDERSHOWERS
|| GetWeatherInCurrentSector( ) == WEATHER_FORECAST_SANDSTORM || GetWeatherInCurrentSector( ) == WEATHER_FORECAST_SNOW ) )
return FALSE;
if( guiCurrentScreen != GAME_SCREEN && guiCurrentScreen != SHOPKEEPER_SCREEN ) return FALSE;
if( guiCurrentScreen != GAME_SCREEN && guiCurrentScreen != SHOPKEEPER_SCREEN )
return FALSE;
return TRUE;
}
@@ -194,7 +184,7 @@ void ResetRain()
}
// Rain
BASE_DROP_SPEED = 7.0f;
BASE_DROP_SPEED = 3.5f;
DROP_SPEED_RANGE = 3.5f;
DROP_SPEED_CHANGE_RATE = 0.1f;
DROP_SPEED_RAND = 5.0f;
@@ -204,8 +194,29 @@ void ResetRain()
void GenerateRainDropsList()
{
// HEADROCK HAM 5 XMAS: More snow than rain.
guiCurrMaxAmountOfRainDrops = (UINT32)(BASE_MAXIMUM_DROPS) * gbCurrentRainIntensity;
switch ( gbCurrentWeather )
{
case WEATHER_FORECAST_NORMAL:
guiCurrMaxAmountOfRainDrops = 0;
break;
case WEATHER_FORECAST_THUNDERSHOWERS:
guiCurrMaxAmountOfRainDrops = (UINT32)(BASE_MAXIMUM_DROPS)* 2;
break;
case WEATHER_FORECAST_SANDSTORM:
guiCurrMaxAmountOfRainDrops = (UINT32)(BASE_MAXIMUM_DROPS)* 8;
break;
case WEATHER_FORECAST_SNOW:
guiCurrMaxAmountOfRainDrops = (UINT32)(BASE_MAXIMUM_DROPS)* 4;
break;
case WEATHER_FORECAST_RAIN:
default:
guiCurrMaxAmountOfRainDrops = (UINT32)(BASE_MAXIMUM_DROPS);
break;
}
pRainDrops = (TRainDrop *)MemAlloc( sizeof( TRainDrop ) * guiCurrMaxAmountOfRainDrops );
memset( pRainDrops, 0, sizeof( TRainDrop ) * guiCurrMaxAmountOfRainDrops );
@@ -213,9 +224,7 @@ void GenerateRainDropsList()
void KillOutOfRegionRainDrops()
{
UINT32 uiIndex;
for( uiIndex = 0; uiIndex < guiCurrMaxAmountOfRainDrops; ++uiIndex )
for ( UINT32 uiIndex = 0; uiIndex < guiCurrMaxAmountOfRainDrops; ++uiIndex )
{
TRainDrop *pCurr = &pRainDrops[ uiIndex ];
@@ -225,9 +234,8 @@ void KillOutOfRegionRainDrops()
pCurr->fpY + pCurr->fpEndRelY < gRainRegion.top || pCurr->fpY + pCurr->fpEndRelY >= gRainRegion.bottom ) )
{
pCurr->fAlive = FALSE;
guiCurrAmountOfDeadRainDrops++;
++guiCurrAmountOfDeadRainDrops;
}
}
}
@@ -342,29 +350,29 @@ void CreateRainDrops()
}
}
uiCreatedDrops++;
++uiCreatedDrops;
// drop creation is done!!!
}
}
void UpdateRainDrops()
{
UINT32 uiIndex;
for( uiIndex = 0; uiIndex < guiCurrMaxAmountOfRainDrops; ++uiIndex )
for ( UINT32 uiIndex = 0; uiIndex < guiCurrMaxAmountOfRainDrops; ++uiIndex )
{
TRainDrop *pCurr = &pRainDrops[ uiIndex ];
if( !pCurr->fAlive )continue;
if( !pCurr->fAlive )
continue;
if( pCurr->uiAmountOfTicksToLive )
{
pCurr->fpX += pCurr->fpIncrX;
pCurr->fpY += pCurr->fpIncrY;
pCurr->uiAmountOfTicksToLive--;
}else{
}
else
{
pCurr->fpEndRelX += pCurr->fpIncrX;
pCurr->fpEndRelY += pCurr->fpIncrY;
@@ -374,11 +382,10 @@ void UpdateRainDrops()
( pCurr->fpEndRelY < 0 && pCurr->fpIncrY < 0 ) )
{
pCurr->fAlive = FALSE;
guiCurrAmountOfDeadRainDrops++;
++guiCurrAmountOfDeadRainDrops;
}
}
}
}
void BlankRainRenderSurface()
@@ -393,7 +400,25 @@ UINT16 GetDropColor()
uiRGBPart = max( 0, uiRGBPart );
uiRGBPart = min( 255, uiRGBPart );
return Get16BPPColor( FROMRGB( uiRGBPart, uiRGBPart, uiRGBPart ) );
UINT32 red = uiRGBPart;
UINT32 green = uiRGBPart;
UINT32 blue = uiRGBPart;
// in a sandstorm, the 'raindrops' are tiny sand particles
if ( GetWeatherInCurrentSector( ) == WEATHER_FORECAST_SANDSTORM )
{
red = 252;
green = 141;
blue = 41;
}
else if ( GetWeatherInCurrentSector() == WEATHER_FORECAST_SNOW )
{
red = 255;
green = 255;
blue = 255;
}
return Get16BPPColor( FROMRGB( red, green, blue ) );
}
void RenderRainOnSurface()
@@ -419,13 +444,26 @@ void RenderRainOnSurface()
UnLockVideoSurface( guiRainRenderSurface );
}
extern UINT32 guiRainLoop;
void GenerateRainMaximums()
{
if( gbCurrentRainIntensity == 1 )
if ( GetWeatherInCurrentSector( ) == WEATHER_FORECAST_THUNDERSHOWERS )
{
fpMinDropAngleOfFalling = 45;
fpMaxDropAngleOfFalling = 135;
}
else if ( GetWeatherInCurrentSector( ) == WEATHER_FORECAST_SANDSTORM )
{
fpMinDropAngleOfFalling = 5;
fpMaxDropAngleOfFalling = 15;
}
else if ( GetWeatherInCurrentSector() == WEATHER_FORECAST_SNOW )
{
fpMinDropAngleOfFalling = 80;
fpMaxDropAngleOfFalling = 100;
}
else
{
if( Random( 2 ) )
@@ -442,46 +480,97 @@ void GenerateRainMaximums()
fpCurrDropAngleOfFalling = fpMinDropAngleOfFalling + Random( (UINT32)(fpMaxDropAngleOfFalling - fpMinDropAngleOfFalling) );
fpMinDropLength = MIN_DROP_LENGTH + ADD_DROP_LENGTH_IF_STORM * ( gbCurrentRainIntensity - 1 );
fpMaxDropLength = fpMinDropLength + DROP_LENGTH_RANGE;
fpMinDropLength = MIN_DROP_LENGTH;
if ( GetWeatherInCurrentSector( ) == WEATHER_FORECAST_THUNDERSHOWERS )
fpMinDropLength += ADD_DROP_LENGTH_IF_STORM;
else if ( GetWeatherInCurrentSector( ) == WEATHER_FORECAST_SANDSTORM || GetWeatherInCurrentSector( ) == WEATHER_FORECAST_SNOW )
fpMinDropLength = 1.0f;
fpMaxDropLength = fpMinDropLength + DROP_LENGTH_RANGE;
fpCurrDropLength = fpMinDropLength + Random( (UINT32)(fpMaxDropLength - fpMinDropLength) );
fpMinDropSpeed = BASE_DROP_SPEED * gbCurrentRainIntensity;
switch ( gbCurrentWeather )
{
case WEATHER_FORECAST_NORMAL:
fpMinDropSpeed = 0;
break;
case WEATHER_FORECAST_THUNDERSHOWERS:
fpMinDropSpeed = BASE_DROP_SPEED * 4;
break;
case WEATHER_FORECAST_SANDSTORM:
fpMinDropSpeed = BASE_DROP_SPEED * 8;
break;
case WEATHER_FORECAST_SNOW:
fpMinDropSpeed = 1.0f;//BASE_DROP_SPEED;
break;
case WEATHER_FORECAST_RAIN:
default:
fpMinDropSpeed = BASE_DROP_SPEED * 2;
break;
}
// haxx
if ( guiRainLoop != NO_SAMPLE )
{
SoundStop( guiRainLoop );
guiRainLoop = NO_SAMPLE;
}
fpMaxDropSpeed = fpMinDropSpeed + DROP_SPEED_RANGE;
fpCurrDropSpeed = fpMinDropSpeed + Random( (UINT32)(fpMaxDropSpeed - fpMinDropSpeed) );
}
void UpdateRainDropsProperities()
{
fpCurrDropAngleOfFalling += Random( (UINT32)(1000 * DROP_ANGLE_CHANGE_RATE * gbCurrentRainIntensity * 2 )) / 1000.0f - DROP_ANGLE_CHANGE_RATE * gbCurrentRainIntensity;
switch ( gbCurrentWeather )
{
case WEATHER_FORECAST_NORMAL:
fpCurrDropAngleOfFalling = 0;
break;
case WEATHER_FORECAST_THUNDERSHOWERS:
fpCurrDropAngleOfFalling += Random( (UINT32)(1000 * DROP_ANGLE_CHANGE_RATE * 4) ) / 1000.0f - DROP_ANGLE_CHANGE_RATE * 2;
break;
case WEATHER_FORECAST_SANDSTORM:
fpCurrDropAngleOfFalling += Random( (UINT32)(1000 * DROP_ANGLE_CHANGE_RATE * 6) ) / 1000.0f - DROP_ANGLE_CHANGE_RATE * 3;
break;
case WEATHER_FORECAST_SNOW:
fpCurrDropAngleOfFalling += Random( (UINT32)(1000 * DROP_ANGLE_CHANGE_RATE * 1) ) / 1000.0f - DROP_ANGLE_CHANGE_RATE * 1;
break;
case WEATHER_FORECAST_RAIN:
default:
fpCurrDropAngleOfFalling += Random( (UINT32)(1000 * DROP_ANGLE_CHANGE_RATE * 2) ) / 1000.0f - DROP_ANGLE_CHANGE_RATE;
break;
}
fpCurrDropAngleOfFalling = max( fpMinDropAngleOfFalling, fpCurrDropAngleOfFalling );
fpCurrDropAngleOfFalling = min( fpMaxDropAngleOfFalling, fpCurrDropAngleOfFalling );
fpCurrDropLength += Random( (UINT32)(1000 * DROP_LENGTH_CHANGE_RATE * 2 )) / 1000.0f - DROP_LENGTH_CHANGE_RATE;
fpCurrDropLength = max( fpMinDropLength, fpCurrDropLength );
fpCurrDropLength = min( fpMaxDropLength, fpCurrDropLength );
fpCurrDropSpeed += Random( (UINT32)(1000 * DROP_SPEED_CHANGE_RATE * 2 )) / 1000.0f - DROP_SPEED_CHANGE_RATE;
fpCurrDropSpeed = max( fpMinDropSpeed, fpCurrDropSpeed );
fpCurrDropSpeed = min( fpMaxDropSpeed, fpCurrDropSpeed );
}
void RandomizeRainDropsPosition()
{
UINT32 uiIndex;
UINT32 ubMoveTo;
for( uiIndex = 0; uiIndex < guiCurrMaxAmountOfRainDrops; ++uiIndex )
for ( UINT32 uiIndex = 0; uiIndex < guiCurrMaxAmountOfRainDrops; ++uiIndex )
{
TRainDrop *pCurr = &pRainDrops[ uiIndex ];
@@ -499,15 +588,13 @@ void RandomizeRainDropsPosition()
}
}
}
}
void RainClipVideoOverlay()
{
UINT32 uiIndex;
BACKGROUND_SAVE *pCurr;
for( uiIndex = 0; uiIndex < guiNumVideoOverlays ; ++uiIndex )
for ( UINT32 uiIndex = 0; uiIndex < guiNumVideoOverlays; ++uiIndex )
{
pCurr = gVideoOverlays[ uiIndex ].pBackground;
@@ -521,13 +608,14 @@ void RainClipVideoOverlay()
void RenderRain()
{
if( !GetRainIntensityFromEnvWeather() && gbCurrentRainIntensity )
if ( !GetWeatherInCurrentSector( ) && gbCurrentWeather )
{
gbCurrentRainIntensity = GetRainIntensityFromEnvWeather();
gbCurrentWeather = GetWeatherInCurrentSector( );
ResetRain();
}
if( !IsItAllowedToRenderRain() )return;
if( !IsItAllowedToRenderRain() )
return;
if( guiCurrentScreen == SHOPKEEPER_SCREEN )
{
@@ -555,14 +643,13 @@ void RenderRain()
else
guiLastRainUpdate = GetJA2Clock();
if( gbCurrentRainIntensity != GetRainIntensityFromEnvWeather() )
if ( gbCurrentWeather != GetWeatherInCurrentSector( ) )
{
gbCurrentRainIntensity = GetRainIntensityFromEnvWeather();
gbCurrentWeather = GetWeatherInCurrentSector( );
ResetRain();
GenerateRainDropsList();
GenerateRainMaximums();
guiCurrAmountOfDeadRainDrops = guiCurrMaxAmountOfRainDrops;
CreateRainDrops();
@@ -590,5 +677,4 @@ void RenderRain()
ColorFillVideoSurfaceArea( guiRainRenderSurface, gTalkPanel.sPopupX, gTalkPanel.sPopupY, (INT16)( gTalkPanel.sPopupX + gPopUpTextBox->sWidth ), (INT16)( gTalkPanel.sPopupY + gPopUpTextBox->sHeight ), Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
}
}
}
+1 -1
View File
@@ -2304,7 +2304,7 @@ BOOLEAN MercIsHot( SOLDIERTYPE * pSoldier )
// Flugente: drugs can temporarily cause a merc to be heat intolerant
if ( !pSoldier->MercInWater( ) && DoesMercHaveDisability( pSoldier, HEAT_INTOLERANT ) )
{
if ((pSoldier->bSectorZ > 0) || (guiEnvWeather & ( WEATHER_FORECAST_SHOWERS | WEATHER_FORECAST_THUNDERSHOWERS )))
if ( (pSoldier->bSectorZ > 0) || (SectorInfo[SECTOR( pSoldier->sSectorX, pSoldier->sSectorY )].usWeather == WEATHER_FORECAST_RAIN || SectorInfo[SECTOR( pSoldier->sSectorX, pSoldier->sSectorY )].usWeather == WEATHER_FORECAST_THUNDERSHOWERS) )
{
// cool underground or raining
return( FALSE );
+1 -19
View File
@@ -2761,25 +2761,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
if( fAlt )
{
if ( CHEATER_CHEAT_LEVEL( ) )
{
EnvBeginRainStorm( 1 );
}
else
{
HandleTacticalStoreInvItem();
}
}
else if( fCtrl )
{
if ( CHEATER_CHEAT_LEVEL( ) )
{
EnvEndRainStorm( );
}
else
{
//HandleTacticalTakeItem();
}
HandleTacticalStoreInvItem( );
}
else
// Switch panels...
+6 -10
View File
@@ -63,11 +63,6 @@ class SOLDIERTYPE;
#include "GameInitOptionsScreen.h"
//rain
//#define WEAPON_RELIABILITY_REDUCTION_PER_RAIN_INTENSITY 0
extern INT8 gbCurrentRainIntensity;
//end rain
// sevenfm: this global variable is needed to correctly set default number of bullets for autofire
extern BOOLEAN gfAutofireInitBulletNum;
@@ -1274,9 +1269,6 @@ void AdjustImpactByHitLocation( INT32 iImpact, UINT8 ubHitLocation, INT32 * piNe
// #define TESTGUNJAM
//rain
extern INT8 gbCurrentRainIntensity;
//end rain
BOOLEAN CheckForGunJam( SOLDIERTYPE * pSoldier )
{
OBJECTTYPE * pObj;
@@ -1295,8 +1287,12 @@ BOOLEAN CheckForGunJam( SOLDIERTYPE * pSoldier )
int maxJamChance = 50; // Externalize this?
int reliability = GetReliability( pObj );
int condition = (*pObj)[0]->data.gun.bGunStatus;
int invertedBaseJamChance = condition + (reliability * 2) -
gGameExternalOptions.ubWeaponReliabilityReductionPerRainIntensity * gbCurrentRainIntensity;
int weatherpenalty = 0;
if ( !pSoldier->bSectorZ )
weatherpenalty = gGameExternalOptions.ubWeaponReliabilityReduction[SectorInfo[SECTOR( pSoldier->sSectorX, pSoldier->sSectorY )].usWeather];
int invertedBaseJamChance = condition + (reliability * 2) - weatherpenalty;
// Flugente: If overheating is allowed, a gun will be prone to more overheating if its temperature is high
if ( gGameExternalOptions.fWeaponOverheating )
+26 -23
View File
@@ -328,7 +328,6 @@ void DECAY_OPPLIST_VALUE( INT8& value )
//rain
extern INT8 gbCurrentRainIntensity;
extern BOOLEAN gfLightningInProgress;
extern BOOLEAN gfHaveSeenSomeone;
extern UINT8 ubRealAmbientLightLevel;
@@ -337,34 +336,25 @@ extern UINT8 ubRealAmbientLightLevel;
INT16 AdjustMaxSightRangeForEnvEffects( SOLDIERTYPE *pSoldier, INT8 bLightLevel, INT16 sDistVisible )
{
INT16 sNewDist = 0;
INT16 sNewDist = sDistVisible * gGameExternalOptions.ubBrightnessVisionMod[bLightLevel] / 100;
//sNewDist = sDistVisible * gbLightSighting[ 0 ][ bLightLevel ] / 100;
sNewDist = sDistVisible * gGameExternalOptions.ubBrightnessVisionMod[ bLightLevel ] / 100;
// Adjust it based on weather...
if ( guiEnvWeather & ( WEATHER_FORECAST_SHOWERS | WEATHER_FORECAST_THUNDERSHOWERS ) )
if ( !pSoldier->bSectorZ )
{
//sNewDist = sNewDist * 70 / 100;
FLOAT weatherpenalty = gGameExternalOptions.dVisDistDecrease[SectorInfo[SECTOR( pSoldier->sSectorX, pSoldier->sSectorY )].usWeather];
FLOAT appliedpenalty = 1.0f;
if ( HAS_SKILL_TRAIT( pSoldier, SURVIVAL_NT ) && (gGameOptions.fNewTraitSystem) )
appliedpenalty = min( 1.0f, max( 0.0f, appliedpenalty - gSkillTraitValues.dSVWeatherPenaltiesReduction * NUM_SKILL_TRAITS( pSoldier, SURVIVAL_NT ) ) );
sNewDist -= (INT16)(sNewDist * weatherpenalty * appliedpenalty);
//rain
//Added a feature reducing weather penalty for ranger trait - SANDRO
INT16 sWeatherPenalty = 0; // percent vision reduction 0-100%
sWeatherPenalty = min( (max( 0, (gGameExternalOptions.ubVisDistDecreasePerRainIntensity * gbCurrentRainIntensity))), 100) ;
if ( gGameOptions.fNewTraitSystem && HAS_SKILL_TRAIT( pSoldier, SURVIVAL_NT ) )
{
sWeatherPenalty = (sWeatherPenalty * (100 - (gSkillTraitValues.ubSVWeatherPenaltiesReduction * NUM_SKILL_TRAITS( pSoldier, SURVIVAL_NT )))) / 100;
sWeatherPenalty = min( (max( 0, sWeatherPenalty)), 100 ); // keep it in 0-100 range
}
sNewDist = (sNewDist * ( 100 - sWeatherPenalty )) / 100;
if ( gfLightningInProgress )
sNewDist += sNewDist * (ubRealAmbientLightLevel) / 10; // 10% per dark level
//end rain
}
//rain
if( gfLightningInProgress )
sNewDist += sNewDist * ( ubRealAmbientLightLevel ) / 10; // 10% per dark level
//end rain
return( sNewDist );
}
@@ -1630,6 +1620,19 @@ INT8 DecideHearing( SOLDIERTYPE * pSoldier )
break;
}
// adjust for weather
if ( !pSoldier->bSectorZ )
{
FLOAT weatherpenalty = gGameExternalOptions.dHearingReduction[SectorInfo[SECTOR( pSoldier->sSectorX, pSoldier->sSectorY )].usWeather];
// Added a feature to reduce rain effect on regaining breath with Ranger trait - SANDRO
FLOAT appliedpenalty = 1.0f;
if ( HAS_SKILL_TRAIT( pSoldier, SURVIVAL_NT ) && gGameOptions.fNewTraitSystem )
appliedpenalty = min( 1.0f, max( 0.0f, appliedpenalty - gSkillTraitValues.dSVWeatherPenaltiesReduction * NUM_SKILL_TRAITS( pSoldier, SURVIVAL_NT ) ) );
bHearing -= (INT16)(bHearing * weatherpenalty * appliedpenalty);
}
return( bHearing );
}