Merge branch 'master' into ExtraMercs

This commit is contained in:
Asdow
2023-07-26 13:17:49 +03:00
754 changed files with 9435 additions and 74371 deletions
+27 -110
View File
@@ -1,6 +1,3 @@
#ifdef PRECOMPILEDHEADERS
#include "Tactical All.h"
#else
#include "items.h"
#include "Action Items.h"
#include "weapons.h"
@@ -61,7 +58,6 @@
#include "DisplayCover.h" // added by Flugente
#include "Map Information.h"
#include "ai.h" // added by Flugente
#endif
#ifdef JA2UB
#include "Ja25_Tactical.h"
@@ -3035,49 +3031,6 @@ UINT16 CalculateItemSize( OBJECTTYPE *pObject )
currentSize = __max(iSize + testSize, currentSize);
currentSize = __min(currentSize, maxSize);
}
#if 0
//old method
UINT16 newSize, testSize, maxSize;
UINT8 cnt=0;
newSize = 0;
maxSize = max(iSize, LoadBearingEquipment[Item[pObject->usItem].ubClassIndex].lbeFilledSize);
// Look for the ItemSize of the largest item in this LBENODE
for(UINT16 x = 0; x < invsize; ++x)
{
if(pLBE->inv[x].exists() == true)
{
testSize = CalculateItemSize(&(pLBE->inv[x]));
//Now that we have the size of one item, we want to factor in the number of items since two
// items take up more space then one.
testSize = testSize + pLBE->inv[x].ubNumberOfObjects - 1;
testSize = min(testSize,34);
//We also need to increase the size of guns so they'll fit with the rest of our calculations.
if(testSize < 5)
testSize += 10;
if(testSize < 10)
testSize += 18;
//Finally, we want to factor in multiple pockets. We'll do this by counting the number of filled
// pockets, then add this count total to our newSize when everything is finished.
cnt++;
newSize = max(testSize, newSize);
}
}
//Add the total number of filled pockets to our NewSize to account for multiple pockets being used
newSize += cnt;
newSize = min(newSize,34);
// If largest item is smaller then LBE, don't change ItemSize
if(newSize > 0 && newSize < iSize) {
iSize = iSize;
}
// if largest item is larget then LBE but smaller then max size, partially increase ItemSize
else if(newSize >= iSize && newSize < maxSize) {
iSize = newSize;
}
// if largest item is larger then max size, reset ItemSize to max size
else if(newSize >= maxSize) {
iSize = maxSize;
}
#endif
}
}
}
@@ -8462,19 +8415,7 @@ BOOLEAN CreateItem( UINT16 usItem, INT16 bStatus, OBJECTTYPE * pObj )
{
(*pObj).fFlags |= OBJECT_UNDROPPABLE;
}
#if 0//dnl ch74 201013 create default attachments rather at gun status instead of 100%
for(UINT8 cnt = 0; cnt < MAX_DEFAULT_ATTACHMENTS; cnt++){
if(Item [ usItem ].defaultattachments[cnt] == 0)
break;
//cannot use gTempObject
OBJECTTYPE defaultAttachment;
CreateItem(Item [ usItem ].defaultattachments[cnt],100,&defaultAttachment);
pObj->AttachObject(NULL,&defaultAttachment, FALSE);
}
#else
AttachDefaultAttachments(pObj);//dnl ch75 261013
#endif
}
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("CreateItem: return %d",fRet));
@@ -12648,44 +12589,7 @@ UINT16 PickARandomLaunchable(UINT16 itemIndex)
UINT16 usNumMatches = 0;
UINT16 usRandom = 0;
UINT16 lowestCoolness = LowestLaunchableCoolness(itemIndex);
#if 0
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("PickARandomLaunchable: itemIndex = %d", itemIndex));
// WANNE: This should fix the hang on the merc positioning screen (fix by Razer)
//while( !usNumMatches )
{ //Count the number of valid launchables
for( i = 0; i < MAXITEMS; ++i )
{
if ( Item[i].usItemClass == 0 )
break;
//Madd: quickfix: make it not choose best grenades right away.
if( ValidLaunchable( i, itemIndex ) && ItemIsLegal(i) && Item[i].ubCoolness <= max(HighestPlayerProgressPercentage()/10,lowestCoolness) )
usNumMatches++;
}
}
if( usNumMatches )
{
usRandom = (UINT16)Random( usNumMatches );
for( i = 0; i < MAXITEMS; ++i )
{
if ( Item[i].usItemClass == 0 )
break;
if( ValidLaunchable( i, itemIndex ) && ItemIsLegal(i) && Item[i].ubCoolness <= max(HighestPlayerProgressPercentage()/10,lowestCoolness) )
{
if( usRandom )
usRandom--;
else
{
return i;
}
}
}
}
#endif
// Flugente: the above code is highly dubious.. why do we loop over all items 2 times, and why that obscure usRandom--; business? This can cause an underflow!
BOOLEAN isnight = NightTime();
UINT16 maxcoolness = max( HighestPlayerProgressPercentage() / 10, lowestCoolness );
@@ -14174,29 +14078,29 @@ INT16 GetFlatToHitBonus( OBJECTTYPE * pObj )
// HEADROCK: Function to get average of all "best laser range" attributes from weapon and attachments
INT16 GetAverageBestLaserRange( OBJECTTYPE * pObj )
{
INT16 bonus=0;
FLOAT bonus = 0.0;
INT16 numModifiers=0;
if (Item[pObj->usItem].bestlaserrange > 0)
{
numModifiers++;
bonus += Item[pObj->usItem].bestlaserrange;
bonus += (FLOAT) Item[pObj->usItem].bestlaserrange;
}
for (attachmentList::iterator iter = (*pObj)[0]->attachments.begin(); iter != (*pObj)[0]->attachments.end(); ++iter)
{
if (Item[iter->usItem].bestlaserrange > 0 && iter->exists())
{
numModifiers++;
bonus += Item[iter->usItem].bestlaserrange;
bonus += (FLOAT) Item[iter->usItem].bestlaserrange;
}
}
if (numModifiers>0)
if (numModifiers > 1)
{
bonus = bonus / numModifiers;
}
return( bonus * gItemSettings.fBestLaserRangeModifier );
return (INT16)(bonus * gItemSettings.fBestLaserRangeModifier);
}
// get the best laser range from the weapon and attachments
@@ -14216,7 +14120,7 @@ INT16 GetBestLaserRange( OBJECTTYPE * pObj )
}
}
return( range * gItemSettings.fBestLaserRangeModifier );
return (INT16) ((FLOAT)range * gItemSettings.fBestLaserRangeModifier);
}
// HEADROCK: This function determines the bipod bonii of the gun or its attachments
@@ -15738,14 +15642,9 @@ BOOLEAN GetItemFromRandomItem( UINT16 usRandomItem, UINT16* pusNewItem )
// as it is also possible to reference to other random items, we also have to check for them
// clear the random item arrays and reset the counters
for ( int i = 0; i < RANDOM_ITEM_MAX_NUMBER; ++i)
randomitemarray[i] = 0;
for ( int i = 0; i < RANDOM_TABOO_MAX; ++i)
{
randomitemtabooarray[i] = 0;
randomitemclasstabooarray[i] = 0;
}
memset(randomitemarray, 0, sizeof(randomitemarray));
memset(randomitemtabooarray, 0, sizeof(randomitemtabooarray));
memset(randomitemclasstabooarray, 0, sizeof(randomitemclasstabooarray));
itemcnt = 0;
rdtaboocnt = 0;
@@ -16111,3 +16010,21 @@ bool HasScopeMagFactorForGun( UINT16 ausItemGun, FLOAT aFactor )
return false;
}
UINT16 GetLaunchableOfExplosionType(UINT16 launcher, UINT8 explosionType)
{
for (int i = 0; i < MAXITEMS; i++)
{
UINT16 launchable = Launchable[i][0];
if (launchable == 0) // if reached end of Launchable list, then stop
break;
if (Launchable[i][1] == launcher)
{
if (Explosive[Item[launchable].ubClassIndex].ubType == explosionType)
return launchable;
}
}
return NOTHING;
}