mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
@@ -1474,24 +1474,43 @@ void ChooseArmourForSoldierCreateStruct( SOLDIERCREATE_STRUCT *pp, INT8 bHelmetC
|
|||||||
// So we are going to try to pick something other than nothing but not guarantee it.
|
// So we are going to try to pick something other than nothing but not guarantee it.
|
||||||
if (gGameExternalOptions.fSoldiersWearAnyArmour)
|
if (gGameExternalOptions.fSoldiersWearAnyArmour)
|
||||||
{
|
{
|
||||||
if (bHelmetClass < MIN_EQUIPMENT_CLASS) bHelmetClass = MIN_EQUIPMENT_CLASS;
|
INT8 i = 0;
|
||||||
if (bVestClass < MIN_EQUIPMENT_CLASS) bVestClass = MIN_EQUIPMENT_CLASS;
|
if (bHelmetClass < 1) bHelmetClass = 1;
|
||||||
if (bLeggingsClass < MIN_EQUIPMENT_CLASS) bLeggingsClass = MIN_EQUIPMENT_CLASS;
|
//search for a non-empty class with items we need
|
||||||
|
for (i = bHelmetClass;i <= 10;i++)
|
||||||
// Make the first attempt for each item type
|
{
|
||||||
usHelmetItem = PickARandomItem(HELMET, pp->ubSoldierClass, bHelmetClass, TRUE);
|
usHelmetItem = PickARandomItem(HELMET, pp->ubSoldierClass, i);
|
||||||
usVestItem = PickARandomItem(VEST, pp->ubSoldierClass, bVestClass, TRUE);
|
//if we find a non-empty class change to that and break
|
||||||
usLeggingsItem = PickARandomItem(LEGS, pp->ubSoldierClass, bLeggingsClass, TRUE);
|
if (usHelmetItem > 0)
|
||||||
|
{
|
||||||
// PickARandomItem(getMatchingCoolness = TRUE) must have a strong reason to return 0 disregarding wantedCoolness
|
bHelmetClass = i;
|
||||||
// we pass, e.g. itemChoices is empty or filled with improper items. So let's make another attempt to ensure we did
|
break;
|
||||||
// all what we can. Unlikely it will help, though.
|
}
|
||||||
if (usHelmetItem == 0)
|
}
|
||||||
usHelmetItem = PickARandomItem(HELMET, pp->ubSoldierClass, bHelmetClass, TRUE);
|
if (bVestClass < 1) bVestClass = 1;
|
||||||
if (usVestItem == 0)
|
//search for a non-empty class with items we need
|
||||||
usVestItem = PickARandomItem(VEST, pp->ubSoldierClass, bVestClass, TRUE);
|
for (i = bVestClass;i <= 10;i++)
|
||||||
if (usLeggingsItem == 0)
|
{
|
||||||
usLeggingsItem = PickARandomItem(LEGS, pp->ubSoldierClass, bLeggingsClass, TRUE);
|
usVestItem = PickARandomItem(VEST, pp->ubSoldierClass, i);
|
||||||
|
//if we find a non-empty class change to that and break
|
||||||
|
if (usVestItem > 0)
|
||||||
|
{
|
||||||
|
bVestClass = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bLeggingsClass < 1) bLeggingsClass = 1;
|
||||||
|
//search for a non-empty class with items we need
|
||||||
|
for (i = bLeggingsClass;i <= 10;i++)
|
||||||
|
{
|
||||||
|
usLeggingsItem = PickARandomItem(LEGS, pp->ubSoldierClass, i);
|
||||||
|
//if we find a non-empty class change to that and break
|
||||||
|
if (usLeggingsItem > 0)
|
||||||
|
{
|
||||||
|
bLeggingsClass = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Madd: added minimum protection of 10 for armours to be used by enemies
|
//Madd: added minimum protection of 10 for armours to be used by enemies
|
||||||
@@ -3339,10 +3358,7 @@ UINT16 PickARandomItem(UINT8 typeIndex, INT8 bSoldierClass, UINT8 wantedCoolness
|
|||||||
if ( i > gArmyItemChoices[bSoldierClass][ typeIndex ].ubChoices )
|
if ( i > gArmyItemChoices[bSoldierClass][ typeIndex ].ubChoices )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (getMatchingCoolness == TRUE)
|
uiChoice = Random(gArmyItemChoices[bSoldierClass][typeIndex].ubChoices + (int)(gArmyItemChoices[bSoldierClass][typeIndex].ubChoices / 3));
|
||||||
uiChoice = Random(gArmyItemChoices[bSoldierClass][typeIndex].ubChoices);
|
|
||||||
else // otherwise there is a chance to pick nothing!
|
|
||||||
uiChoice = Random(gArmyItemChoices[bSoldierClass][typeIndex].ubChoices + (int)(gArmyItemChoices[bSoldierClass][typeIndex].ubChoices / 3));
|
|
||||||
|
|
||||||
if ( uiChoice >= gArmyItemChoices[bSoldierClass][ typeIndex ].ubChoices )
|
if ( uiChoice >= gArmyItemChoices[bSoldierClass][ typeIndex ].ubChoices )
|
||||||
{
|
{
|
||||||
@@ -3364,7 +3380,7 @@ UINT16 PickARandomItem(UINT8 typeIndex, INT8 bSoldierClass, UINT8 wantedCoolness
|
|||||||
|
|
||||||
pickItem = FALSE;
|
pickItem = FALSE;
|
||||||
|
|
||||||
if (usItem > 0 && Item[usItem].randomitem == 0 && ItemIsLegal(usItem))
|
if (usItem >= 0 && Item[usItem].ubCoolness <= wantedCoolness && ItemIsLegal(usItem))
|
||||||
{
|
{
|
||||||
// On day
|
// On day
|
||||||
if (DayTime() == TRUE)
|
if (DayTime() == TRUE)
|
||||||
@@ -3386,6 +3402,9 @@ UINT16 PickARandomItem(UINT8 typeIndex, INT8 bSoldierClass, UINT8 wantedCoolness
|
|||||||
pickItem = TRUE;
|
pickItem = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Item[usItem].randomitem > 0)
|
||||||
|
pickItem = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3395,8 +3414,7 @@ UINT16 PickARandomItem(UINT8 typeIndex, INT8 bSoldierClass, UINT8 wantedCoolness
|
|||||||
if (pickItem == TRUE)
|
if (pickItem == TRUE)
|
||||||
{
|
{
|
||||||
// pick a default item in case we don't find anything with a matching coolness, but pick the most matching (by coolness) item
|
// pick a default item in case we don't find anything with a matching coolness, but pick the most matching (by coolness) item
|
||||||
if ( defaultItem == 0 ||
|
if (defaultItem == 0 || Item[usItem].ubCoolness > Item[defaultItem].ubCoolness)
|
||||||
abs((int)wantedCoolness - (int)Item[usItem].ubCoolness) < abs((int)wantedCoolness - (int)Item[defaultItem].ubCoolness))
|
|
||||||
{
|
{
|
||||||
defaultItem = usItem;
|
defaultItem = usItem;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user