mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
New feature: advanced repair/dirt system
- items now have an internal repair value that can be lowered through damage taken. They can only be repaired up to that value by your mercs, onyl smiths can fully restore it to 100% - guns get dirty over time, especially when shooting. Thsi can cause them to jam. Use cleaning kits (item #1576) to clean them by pressing 'Alt' + '.' - more on this feature in http://www.bears-pit.com/board/ubbthreads.php/topics/308926/New_feature_advanced_repair_di.html#Post308926 - this requires GameDir revision 1496 or higher WARING! THIS BREAKS SAVEGAME COMPATIBIITY! git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5480 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -48,6 +48,11 @@
|
||||
class OBJECTTYPE;
|
||||
class SOLDIERTYPE;
|
||||
|
||||
// Flugente: external sector data
|
||||
extern SECTOR_EXT_DATA SectorExternalData[256][4];
|
||||
|
||||
extern void SetLastTimePlayerWasInSector(INT16 sMapX, INT16 sMapY, INT8 sMapZ); // Flugente: set last time sector was visited
|
||||
|
||||
//dnl ch51 081009
|
||||
UINT8 gInventoryPoolIndex = '0';
|
||||
std::vector<WORLDITEM> pInventoryPoolListQ[INVPOOLLISTNUM];
|
||||
@@ -5069,6 +5074,14 @@ void SectorInventoryCooldownFunctions( INT16 sMapX, INT16 sMapY, INT16 sMapZ )
|
||||
//Save the Items to the the file
|
||||
SaveWorldItemsToTempItemFile( sMapX, sMapY, (INT8)sMapZ, uiTotalNumberOfRealItems, pTotalSectorList );
|
||||
}
|
||||
|
||||
HandleSectorCooldownFunctions( sMapX, sMapY, (INT8)sMapZ, pTotalSectorList, uiTotalNumberOfRealItems, TRUE );
|
||||
|
||||
//Save the time the player was last in the sector
|
||||
SetLastTimePlayerWasInSector( sMapX, sMapY, (INT8)sMapZ );
|
||||
|
||||
//Save the Items to the the file
|
||||
SaveWorldItemsToTempItemFile( sMapX, sMapY, (INT8)sMapZ, uiTotalNumberOfRealItems, pTotalSectorList );
|
||||
}
|
||||
|
||||
// Flugente: handle various cooldwon functions over an array of items in a specific sector.
|
||||
@@ -5077,7 +5090,7 @@ void SectorInventoryCooldownFunctions( INT16 sMapX, INT16 sMapY, INT16 sMapZ )
|
||||
void HandleSectorCooldownFunctions( INT16 sMapX, INT16 sMapY, INT8 sMapZ, WORLDITEM* pWorldItem, UINT32 size, BOOLEAN fWithMinutes )
|
||||
{
|
||||
// if not using overheating or food system, no point in all this
|
||||
if ( !gGameOptions.fWeaponOverheating && !gGameOptions.fFoodSystem )
|
||||
if ( !gGameOptions.fWeaponOverheating && !gGameExternalOptions.fDirtSystem && !gGameOptions.fFoodSystem )
|
||||
return;
|
||||
|
||||
UINT32 tickspassed = 1;
|
||||
@@ -5105,6 +5118,16 @@ void HandleSectorCooldownFunctions( INT16 sMapX, INT16 sMapY, INT8 sMapZ, WORLDI
|
||||
if ( sMapZ > 0 )
|
||||
foofdecaymod *= 0.8f;
|
||||
|
||||
// get sector-specific dirt threshold
|
||||
UINT16 sectormod = 0;
|
||||
UINT8 ubSectorId = SECTOR(sMapX, sMapY);
|
||||
if ( sMapZ > 0 )
|
||||
sectormod = 100;
|
||||
else if ( ubSectorId >= 0 && ubSectorId < 256 )
|
||||
{
|
||||
sectormod = SectorExternalData[ubSectorId][sMapZ].usNaturalDirt;
|
||||
}
|
||||
|
||||
for( UINT32 uiCount = 0; uiCount < size; ++uiCount ) // ... for all items in the world ...
|
||||
{
|
||||
if( pWorldItem[ uiCount ].fExists ) // ... if item exists ...
|
||||
@@ -5158,6 +5181,24 @@ void HandleSectorCooldownFunctions( INT16 sMapX, INT16 sMapY, INT8 sMapZ, WORLDI
|
||||
}
|
||||
}
|
||||
|
||||
if ( gGameExternalOptions.fDirtSystem && ( (Item[pObj->usItem].usItemClass & IC_WEAPON) || (Item[pObj->usItem].usItemClass & IC_ARMOUR) ) )
|
||||
{
|
||||
FLOAT dirtincreasefactor = GetItemDirtIncreaseFactor(pObj, FALSE); // ... get dirt increase factor ...
|
||||
|
||||
// the current sector determines how much dirt increases
|
||||
dirtincreasefactor *= (sectormod)/100;
|
||||
|
||||
dirtincreasefactor /= gGameExternalOptions.usSectorDirtDivider;
|
||||
|
||||
if ( dirtincreasefactor > 0.0f ) // ... item can get dirtier ...
|
||||
{
|
||||
for(INT16 i = 0; i < pObj->ubNumberOfObjects; ++i) // ... there might be multiple items here (item stack), so for each one ...
|
||||
{
|
||||
(*pObj)[i]->data.bDirtLevel = max(0.0f, min( OVERHEATING_MAX_TEMPERATURE, (*pObj)[i]->data.bDirtLevel + tickspassed * dirtincreasefactor) ); // set new temperature
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( gGameOptions.fFoodSystem && Item[pWorldItem[ uiCount ].object.usItem].foodtype > 0 ) // ... if it is food and the food system is active ...
|
||||
{
|
||||
if ( Food[Item[pObj->usItem].foodtype].usDecayRate > 0.0f ) // ... if the food can decay...
|
||||
|
||||
Reference in New Issue
Block a user