diff --git a/Strategic/Assignments.cpp b/Strategic/Assignments.cpp
index aa7e63b9..19cbecc5 100644
--- a/Strategic/Assignments.cpp
+++ b/Strategic/Assignments.cpp
@@ -4386,7 +4386,7 @@ void RestCharacter( SOLDIERTYPE *pSoldier )
// handle the sleep of this character, update bBreathMax based on sleep they have
INT8 bMaxBreathRegain = 0;
INT16 sSectorModifier = 100;
- INT8 bDivisor = 0;
+ FLOAT bDivisor = 0;
// Determine how many hours a day this merc must sleep. Normally this would range between 6 and 12 hours.
// Injuries and/or martial arts trait can change the limits to between 3 and 18 hours a day.
@@ -4394,7 +4394,8 @@ void RestCharacter( SOLDIERTYPE *pSoldier )
// HEADROCK HAM 3.6:
// Night ops specialists sleep better during the day. Others sleep better during the night.
- if (NightTime())
+ // silversurfer: The code below did the complete opposite. A higher bDivisor means LESS regeneration. Fixed.
+ if (DayTime()) //if (NightTime())
{
if ( gGameOptions.fNewTraitSystem ) // SANDRO - Old/New traits
{
@@ -4415,25 +4416,6 @@ void RestCharacter( SOLDIERTYPE *pSoldier )
bDivisor += (2*NUM_SKILL_TRAITS( pSoldier, NIGHTOPS_OT ));
}
-
- // Re-enforce limits
- bDivisor = __min(18, __max(3, bDivisor));
-
- bMaxBreathRegain = 50 / bDivisor;
-
- // Limit so that characters can't regain faster than 3 hours, ever
- if (bMaxBreathRegain > 17)
- {
- bMaxBreathRegain = 17;
- }
-
- // if breath max is below the "really tired" threshold
- if( pSoldier->bBreathMax < BREATHMAX_PRETTY_TIRED )
- {
- // real tired, rest rate is 50% higher (this is to prevent absurdly long sleep times for totally exhausted mercs)
- bMaxBreathRegain = ( bMaxBreathRegain * 3 / 2 );
- }
-
// HEADROCK HAM 3.5: Read adjustment from local sector facilities
if (pSoldier->bSectorZ == 0)
{
@@ -4448,7 +4430,34 @@ void RestCharacter( SOLDIERTYPE *pSoldier )
// then only Ambient effects take place.
sSectorModifier = GetSectorModifier( pSoldier, FACILITY_PERFORMANCE_MOD );
}
- bMaxBreathRegain = (bMaxBreathRegain * sSectorModifier) / 100;
+ bDivisor = (bDivisor * 100) / sSectorModifier;
+ }
+
+ // silversurfer: Items can provide a bonus to regeneration, sleeping bags for example.
+ // They will not provide such bonus if the merc is already using a bed in a facility.
+ if ( GetSoldierFacilityAssignmentIndex( pSoldier ) != FAC_PATIENT && GetSoldierFacilityAssignmentIndex( pSoldier ) != FAC_REST )
+ {
+ bDivisor = ( bDivisor * 100 ) / ( 100 + GetInventorySleepModifier( pSoldier ) );
+ }
+
+ // silversurfer: I moved all modifiers above this point because we don't want anybody to rest faster or slower than the already extreme thresholds.
+ // Re-enforce limits
+ bDivisor = __min(18, __max(3, bDivisor));
+
+ // round up so the bonuses above make more sense
+ bMaxBreathRegain = ( 50 / bDivisor + 0.5 );
+
+ // Limit so that characters can't regain faster than 3 hours, ever
+ if (bMaxBreathRegain > 17)
+ {
+ bMaxBreathRegain = 17;
+ }
+
+ // if breath max is below the "really tired" threshold
+ if( pSoldier->bBreathMax < BREATHMAX_PRETTY_TIRED )
+ {
+ // real tired, rest rate is 50% higher (this is to prevent absurdly long sleep times for totally exhausted mercs)
+ bMaxBreathRegain = (UINT8)( bMaxBreathRegain * 3 / 2 );
}
pSoldier->bBreathMax += bMaxBreathRegain;
diff --git a/Tactical/Item Types.h b/Tactical/Item Types.h
index 2b6e6871..ebeb1950 100644
--- a/Tactical/Item Types.h
+++ b/Tactical/Item Types.h
@@ -1160,6 +1160,9 @@ typedef struct
// Flugente: item is connected to another item. Type of connection depends on item specifics
UINT16 usBuddyItem;
+ // silversurfer: item provides breath regeneration bonus while resting
+ UINT8 ubSleepModifier;
+
} INVTYPE;
diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp
index 2d9a7b60..f46bb90d 100644
--- a/Tactical/Items.cpp
+++ b/Tactical/Items.cpp
@@ -15257,3 +15257,18 @@ INT32 GetPercentRangeBonus( OBJECTTYPE * pObj )
return( bonus );
}
+// silversurfer: Finds items with SleepModifier bonus in inventory and returns the highest value
+UINT8 GetInventorySleepModifier( SOLDIERTYPE *pSoldier )
+{
+ UINT8 modifier = 0;
+
+ for ( UINT8 i = 0; i < pSoldier->inv.size(); i++ )
+ {
+ if( pSoldier->inv[ i ].exists() == true && Item[ pSoldier->inv[i].usItem ].ubSleepModifier > 0 )
+ {
+ modifier = __max(modifier, BonusReduce( Item[ pSoldier->inv[i].usItem ].ubSleepModifier, pSoldier->inv[i][0]->data.objectStatus ));
+ }
+ }
+
+ return( modifier );
+}
\ No newline at end of file
diff --git a/Tactical/Items.h b/Tactical/Items.h
index 3a06bcb6..cce3479a 100644
--- a/Tactical/Items.h
+++ b/Tactical/Items.h
@@ -520,6 +520,9 @@ BOOLEAN ItemCanBeAppliedToOthers( UINT16 usItem );
//zwwooooo - IoV: change RangeBonus to ratable (Orange by kenkenkenken in IoV921)
INT32 GetPercentRangeBonus( OBJECTTYPE * pObj );
+// silversurfer: returns the SleepModifier from the characters inventory
+UINT8 GetInventorySleepModifier( SOLDIERTYPE *pSoldier );
+
#endif
diff --git a/Tactical/Weapons.h b/Tactical/Weapons.h
index bf5fbfee..c8980b6c 100644
--- a/Tactical/Weapons.h
+++ b/Tactical/Weapons.h
@@ -47,7 +47,7 @@ void HandleTacticalEffectsOfEquipmentChange( SOLDIERTYPE *pSoldier, UINT32 uiInv
#define SOLID_SLUG_RANGE_BONUS 65
#define DUCKBILL_RANGE_BONUS 40
-#define MAX_PERCENT_NOISE_VOLUME_FOR_SILENCED_SOUND 35
+#define MAX_PERCENT_NOISE_VOLUME_FOR_SILENCED_SOUND 50 //35 silversurfer changed that to make sound suppressors always play the silenced sound
// JA2 GOLD: for weapons and attachments, give penalties only for status values below 85
#define WEAPON_STATUS_MOD( x ) ( (x) >= 85 ? 100 : (((x) * 100) / 85) )
diff --git a/Utils/XML_Items.cpp b/Utils/XML_Items.cpp
index da197414..1e2afe64 100644
--- a/Utils/XML_Items.cpp
+++ b/Utils/XML_Items.cpp
@@ -270,13 +270,15 @@ itemStartElementHandle(void *userData, const XML_Char *name, const XML_Char **at
strcmp(name, "CrowbarModifier") == 0 ||
strcmp(name, "DisarmModifier") == 0 ||
strcmp(name, "RepairModifier") == 0 ||
+
strcmp(name, "usActionItemFlag") == 0 ||
strcmp(name, "clothestype") == 0 ||
strcmp(name, "randomitem") == 0 ||
strcmp(name, "randomitemcoolnessmodificator") == 0 ||
strcmp(name, "FlashLightRange") == 0 ||
strcmp(name, "ItemChoiceTimeSetting") == 0 ||
- strcmp(name, "buddyitem") == 0 ))
+ strcmp(name, "buddyitem") == 0 ||
+ strcmp(name, "SleepModifier") == 0))
{
pData->curElement = ELEMENT_PROPERTY;
//DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("itemStartElementHandle: going into element, name = %s",name) );
@@ -1431,6 +1433,11 @@ itemEndElementHandle(void *userData, const XML_Char *name)
pData->curElement = ELEMENT;
pData->curItem.usBuddyItem = (UINT16) atol(pData->szCharData);
}
+ else if(strcmp(name, "SleepModifier") == 0)
+ {
+ pData->curElement = ELEMENT;
+ pData->curItem.ubSleepModifier = (UINT16) atol(pData->szCharData);
+ }
pData->maxReadDepth--;
}
@@ -2072,6 +2079,7 @@ BOOLEAN WriteItemStats()
FilePrintf(hFile,"\t\t%d\r\n", Item[cnt].usFlashLightRange );
FilePrintf(hFile,"\t\t%d\r\n", Item[cnt].usItemChoiceTimeSetting );
FilePrintf(hFile,"\t\t%d\r\n", Item[cnt].usBuddyItem );
+ FilePrintf(hFile,"\t\t%d\r\n", Item[cnt].ubSleepModifier );
FilePrintf(hFile,"\t\r\n");
}