









Re: Feature: Overheating Weapons[message #325839]

Sat, 28 September 2013 11:44


silversurfer 

Messages:2791
Registered:May 2009 


Sorry I think I used the wrong term there. That code was made inactive in rev 2207. It hasn't been used anymore since then. The new code was this:
Toggle Spoiler
// Algorithm for jamming
int maxJamChance = 50; // Externalize this?
int reliability = GetReliability( pObj );
int condition = (*pObj)[0]>data.gun.bGunStatus;
int invertedBaseJamChance = condition + (reliability * 2)  gGameExternalOptions.ubWeaponReliabilityReductionPerRainIntensity * gbCurrentRainIntensity;
if (invertedBaseJamChance < 0)
invertedBaseJamChance = 0;
else if (invertedBaseJamChance > 100)
invertedBaseJamChance = 100;
int jamChance = 100  (int)sqrt((double)invertedBaseJamChance * ((75.0(int)(pSoldier>bDoBurst>1)*15) + (double)invertedBaseJamChance / 2.0));
if (jamChance < 0)
jamChance = 0;
else if (jamChance > maxJamChance  reliability)
jamChance = maxJamChance  reliability;
That code hasn't changed much since rev 2207 except for Flugente's additions of weapon overheating and dirt feature which seem to work nicely. This is the current code:
Toggle Spoiler
// Algorithm for jamming
int maxJamChance = 50; // Externalize this?
int reliability = GetReliability( pObj );
int condition = (*pObj)[0]>data.gun.bGunStatus;
int invertedBaseJamChance = condition + (reliability * 2)  gGameExternalOptions.ubWeaponReliabilityReductionPerRainIntensity * gbCurrentRainIntensity;
// Flugente: If overheating is allowed, a gun will be prone to more overheating if its temperature is high
if ( gGameExternalOptions.fWeaponOverheating )
{
FLOAT overheatjampercentage = GetGunOverheatJamPercentage( pObj ); // how much above the gun's usOverheatingJamThreshold are we? ...
int overheatjamfactor = (int)(100* overheatjampercentage); // We need an integer value and rough percentages
overheatjamfactor = max(0, overheatjamfactor  100); // If we haven't reached the OverheatJamThreshold, no increased chance of jamming because of overheating
invertedBaseJamChance = overheatjamfactor; // lower invertedBaseJamChance (thereby increasing jamChance later on)
}
// Flugente: dirt can also influence a gun's jamming behaviour
if ( gGameExternalOptions.fDirtSystem )
{
FLOAT dirtpercentage = (*pObj)[0]>data.bDirtLevel / OVERHEATING_MAX_TEMPERATURE;
int dirtjamfactor = (int)(100 * dirtpercentage*dirtpercentage);
invertedBaseJamChance = dirtjamfactor;
}
if (invertedBaseJamChance < 0)
invertedBaseJamChance = 0;
else if (invertedBaseJamChance > 100)
invertedBaseJamChance = 100;
int jamChance = 100;
if ( pSoldier>ubAttackingHand == SECONDHANDPOS && pSoldier>IsValidSecondHandBurst() )
jamChance = (int)sqrt((double)invertedBaseJamChance * ((75.0(int)((pSoldier>bDoBurst/2)>1)*15) + (double)invertedBaseJamChance / 2.0));
else
jamChance = (int)sqrt((double)invertedBaseJamChance * ((75.0(int)(pSoldier>bDoBurst>1)*15) + (double)invertedBaseJamChance / 2.0));
if (jamChance < 0)
jamChance = 0;
else if (jamChance > maxJamChance  reliability)
jamChance = maxJamChance  reliability;
The only thing that I don't understand is why he multiplies with "dirtpercentage" twice.
Simple example calculation for a single shot with a weapon that is at 100%, no heat system, no dirt system, no rain, no reliability modifier, no burst. This is the "perfect" scenario:
invertedBaseJamChance = 100 + 0*2 + rain intensity*0 = 100
jamChance = 100  sqrt ( 100 * (75  0*15 + 100 /2 ) = 100  sqrt ( 100 * 125 ) = 100  111 = 11
edit: This means that a weapon in perfect condition will never jam under these circumstances.
A weapon that is at 80% status will have a 5% chance of jamming under perfect circumstances and so on.
Temperature and/or dirt will modify the chance of weapon jamming so as long as they are activated we can expect our weapons to jam more frequently.
[Updated on: Sat, 28 September 2013 17:56] by Moderator Report message to a moderator






















