- militia equipment choosing: object status is taken into consideration for NVGs and sungoggles

- militia equipemnt choosing: do not give a 'bonus' for excess ammo we wouldn't take anyway

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5987 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2013-04-07 00:49:08 +00:00
parent e043ce0e70
commit a66a3ef61b
+4 -3
View File
@@ -3595,7 +3595,7 @@ UINT32 ItemFitness( OBJECTTYPE* pObj, UINT8 idx )
}
else
{
value += (NightTime() ? Item[ pObj->usItem ].nightvisionrangebonus : Item[ pObj->usItem ].dayvisionrangebonus );
value = (*pObj)[idx]->data.objectStatus * (NightTime() ? Item[ pObj->usItem ].nightvisionrangebonus : Item[ pObj->usItem ].dayvisionrangebonus );
}
}
else if ( Item[ pObj->usItem ].usItemClass & (IC_BLADE|IC_PUNCH) )
@@ -3632,7 +3632,8 @@ UINT32 GetNeededTotalAmmo( UINT16 usItem )
// special version of ItemFitness() that takes ammo count into consideration
UINT32 ItemFitness_WithAmmo( OBJECTTYPE* pObj, UINT8 idx, UINT32 uiBullets )
{
return (ItemFitness(pObj, idx) * uiBullets) / max(1, GetNeededTotalAmmo(pObj->usItem));
UINT32 optimalammo = GetNeededTotalAmmo(pObj->usItem);
return (ItemFitness(pObj, idx) * min(uiBullets, optimalammo) ) / max(1, optimalammo);
}
// retreives the next free slot in pWorldItem (we want to keep it short and not add too many items)
@@ -3975,7 +3976,7 @@ void MoveMilitiaEquipment(INT16 sSourceX, INT16 sSourceY, INT16 sTargetX, INT16
// This function loads the sector inventory of a given sector and fills the inventory of a SOLDIERCREATE_STRUCT according to the game settings. The soldier class is a parameter, but is currently not used
// This function is rather lengthy, this is due to the fact that we have to loop over the entire sector inventory mulitple times. Below is a small documentation. If you change anything, please update it - Flugente
// We loop over the inventory 3 times. I'll briefly explain why. After each loop we do a few other things - like taking items or doin further evaluation
// We loop over the inventory 3 times. I'll briefly explain why. After each loop we do a few other things - like taking items or doing further evaluation
// Note that any items we checked have to be reachable AND not be 'taboo' to the militia.
// Preparation: load correct sector inventory