From a66a3ef61b9769381b10b1e55985c6e7daaed6e3 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 7 Apr 2013 00:49:08 +0000 Subject: [PATCH] - 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 --- Tactical/Inventory Choosing.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Tactical/Inventory Choosing.cpp b/Tactical/Inventory Choosing.cpp index 6ab65794..90aa2045 100644 --- a/Tactical/Inventory Choosing.cpp +++ b/Tactical/Inventory Choosing.cpp @@ -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