- random items can also be results of merges and item transformations

- removed a few instances of incorrect random item spawning

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5598 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2012-10-01 20:42:55 +00:00
parent 7ef76bbe35
commit fc49b33398
3 changed files with 38 additions and 4 deletions
+8
View File
@@ -1042,6 +1042,10 @@ void ChooseWeaponForSoldierCreateStruct( SOLDIERCREATE_STRUCT *pp, INT8 bWeaponC
if ( GetItemFromRandomItem(usGunIndex, &newitemfromrandom) )
usGunIndex = newitemfromrandom;
// if item is still radnom, use default gun -> GLOCK 17
if ( Item[usGunIndex].randomitem > 0 )
usGunIndex = GLOCK_17;
//WarmSteel - Removed the attachment check here. why check twice anyway?
//Now, we have chosen all of the correct items. Now, we will assign them into the slots.
//Because we are dealing with enemies, automatically give them full ammo in their weapon.
@@ -3471,6 +3475,10 @@ UINT16 PickARandomItem(UINT8 typeIndex, UINT8 maxCoolness, BOOLEAN getMatchingCo
pickItem = TRUE;
}
}
// Flugente: if item is still random, don't pick it
if ( Item[usItem].randomitem > 0 )
pickItem = FALSE;
}
+4 -1
View File
@@ -1328,10 +1328,13 @@ OBJECTTYPE& OBJECTTYPE::operator=(const OLD_OBJECTTYPE_101& src)
}
// Flugente: random items
UINT16 newitemfromrandom = 0;
UINT16 newitemfromrandom = NONE;
if ( GetItemFromRandomItem(src.usItem, &newitemfromrandom) )
this->usItem = newitemfromrandom;
if ( Item[this->usItem].randomitem > 0 )
this->usItem = NONE;
//and now the big change, the union
//copy the old data, making sure not to write over, since the old size is actually 9 bytes
if (ubNumberOfObjects == 1) {
+26 -3
View File
@@ -2783,13 +2783,24 @@ BOOLEAN EvaluateValidMerge( UINT16 usMerge, UINT16 usItem, UINT16 * pusResult, U
}
}
// Flugente: for random items, we have to do the resolution here
UINT16 result1 = Merge[iLoop][2];
UINT16 rdresult1 = 0;
if ( GetItemFromRandomItem(result1, &rdresult1) )
result1 = rdresult1;
UINT16 result2 = Merge[iLoop][3];
UINT16 rdresult2 = 0;
if ( GetItemFromRandomItem(result2, &rdresult2) )
result2 = rdresult2;
//WarmSteel - Return false if the results aren't valid.
if( !ItemIsLegal(Merge[iLoop][2], TRUE) && !ItemIsLegal(Merge[iLoop][3], TRUE) ){
if( !ItemIsLegal(result1, TRUE) && !ItemIsLegal(result2, TRUE) ){
return( FALSE );
}
*pusResult = Merge[iLoop][2];
*pusResult2 = Merge[iLoop][3];
*pusResult = result1;
*pusResult2 = result2;
*pubType = (UINT8) Merge[iLoop][4];
*pubAPCost = (UINT8) Merge[iLoop][5];
return( TRUE );
@@ -7655,6 +7666,12 @@ BOOLEAN CreateItem( UINT16 usItem, INT16 bStatus, OBJECTTYPE * pObj )
if ( GetItemFromRandomItem(usItem, &newitemfromrandom) )
usItem = newitemfromrandom;
if (usItem == 0)
{
DebugBreakpoint();
return( FALSE );
}
if (Item[ usItem ].usItemClass == IC_GUN)
{
fRet = CreateGun( usItem, bStatus, pObj );
@@ -14031,6 +14048,12 @@ BOOLEAN OBJECTTYPE::TransformObject( SOLDIERTYPE * pSoldier, UINT8 ubStatusIndex
if (Transform->usResult[curResult] > 0)
{
usResult[curResult] = Transform->usResult[curResult];
// Flugente: resolution of random items
UINT16 rdresult = 0;
if ( GetItemFromRandomItem(usResult[curResult], &rdresult) )
usResult[curResult] = rdresult;
// Count the number of valid result items
iNumResults++;
}