mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
- improved cooldown/decay functions. every time a sector inventory gets loaded, its inventory gets cooled down, thus all accessible world items always have the correct values.
- OVERHEATING_SET_ZERO_UPON_NEW_SECTOR is not used anymore git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5443 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
#include "Quests.h"
|
||||
#include "Soldier Profile.h"
|
||||
#include "message.h"
|
||||
#include "Food.h" // added by Flugente
|
||||
#include "map screen interface map inventory.h" // added by Flugente
|
||||
#include "connect.h"
|
||||
#endif
|
||||
|
||||
@@ -827,88 +827,8 @@ void RefreshWorldItemsIntoItemPools( WORLDITEM * pItemList, INT32 iNumberOfItems
|
||||
}
|
||||
|
||||
|
||||
// Flugente FTW 1: Cool down all items in the world (no, really)
|
||||
// fSetZero sets all temperatures to 0 (used in old sector upon loading a new sector)
|
||||
void CoolDownWorldItems( BOOLEAN fSetZero )
|
||||
// Flugente: Cool/decay down all items in this sector
|
||||
void CoolDownWorldItems()
|
||||
{
|
||||
if ( gGameOptions.fWeaponOverheating ) // if Overheating is used ...
|
||||
{
|
||||
for( UINT32 uiCount = 0; uiCount < guiNumWorldItems; ++uiCount ) // ... for all items in the world ...
|
||||
{
|
||||
if( gWorldItems[ uiCount ].fExists ) // ... if item exists ...
|
||||
{
|
||||
// ... if Item exists and is a gun, a launcher or a barrel ...
|
||||
if (Item[gWorldItems[ uiCount ].object.usItem].usItemClass & (IC_GUN|IC_LAUNCHER) || Item[gWorldItems[ uiCount ].object.usItem].barrel == TRUE )
|
||||
{
|
||||
OBJECTTYPE* pObj = &(gWorldItems[ uiCount ].object); // ... get pointer for this item ...
|
||||
|
||||
if ( pObj != NULL ) // ... if pointer is not obviously useless ...
|
||||
{
|
||||
for(INT16 i = 0; i < pObj->ubNumberOfObjects; ++i) // ... there might be multiple items here (item stack), so for each one ...
|
||||
{
|
||||
FLOAT newguntemperature = 0.0f;
|
||||
|
||||
if ( !fSetZero || !gGameExternalOptions.fSetZeroUponNewSector )
|
||||
{
|
||||
FLOAT guntemperature = (*pObj)[i]->data.bTemperature; // ... get temperature ...
|
||||
|
||||
FLOAT cooldownfactor = GetItemCooldownFactor(pObj); // ... get item cooldown factor provided of attachments ...
|
||||
|
||||
if ( Item[gWorldItems[ uiCount ].object.usItem].barrel == TRUE ) // ... a barrel lying around cools down a bit faster ...
|
||||
cooldownfactor *= gGameExternalOptions.iCooldownModificatorLonelyBarrel;
|
||||
|
||||
newguntemperature = max(0.0f, guntemperature - cooldownfactor); // ... calculate new temperature ...
|
||||
|
||||
#if 0//def JA2TESTVERSION
|
||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"World: Item temperature lowered from %4.2f to %4.2f", guntemperature, newguntemperature );
|
||||
#endif
|
||||
}
|
||||
|
||||
(*pObj)[i]->data.bTemperature = newguntemperature; // ... set new temperature
|
||||
|
||||
// for every objects, we also have to check wether there are weapon attachments (eg. underbarrel grenade launchers), and cool them down too
|
||||
attachmentList::iterator iterend = (*pObj)[i]->attachments.end();
|
||||
for (attachmentList::iterator iter = (*pObj)[i]->attachments.begin(); iter != iterend; ++iter)
|
||||
{
|
||||
if ( iter->exists() && Item[ iter->usItem ].usItemClass & (IC_GUN|IC_LAUNCHER) )
|
||||
{
|
||||
FLOAT newtemperature = 0.0f;
|
||||
|
||||
if ( !fSetZero || !gGameExternalOptions.fSetZeroUponNewSector )
|
||||
{
|
||||
FLOAT temperature = (*iter)[i]->data.bTemperature; // ... get temperature of item ...
|
||||
|
||||
FLOAT cooldownfactor = GetItemCooldownFactor( &(*iter) ); // ... get cooldown factor ...
|
||||
|
||||
newtemperature = max(0.0f, temperature - cooldownfactor); // ... calculate new temperature ...
|
||||
}
|
||||
|
||||
(*iter)[i]->data.bTemperature = newtemperature; // ... set new temperature
|
||||
|
||||
#if 0//def JA2TESTVERSION
|
||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"World: Item temperature lowered from %4.2f to %4.2f", temperature, newtemperature );
|
||||
#endif
|
||||
|
||||
// we assume that there can exist only 1 UGL per weapon
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( Item[gWorldItems[ uiCount ].object.usItem].foodtype > 0 ) // food decays
|
||||
{
|
||||
OBJECTTYPE* pObj = &(gWorldItems[ uiCount ].object); // ... get pointer for this item ...
|
||||
|
||||
if ( pObj != NULL ) // ... if pointer is not obviously useless ...
|
||||
{
|
||||
for(INT16 i = 0; i < pObj->ubNumberOfObjects; ++i) // ... there might be multiple items here (item stack), so for each one ...
|
||||
{
|
||||
(*pObj)[i]->data.bTemperature = max(0.0f, (*pObj)[i]->data.bTemperature - Food[Item[pObj->usItem].foodtype].usDecayRate); // set new temperature
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HandleSectorCooldownFunctions( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, gWorldItems, guiNumWorldItems, FALSE );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user