new item tag <ItemChoiceTimeSetting> forbids AI from picking an item at night if set to 1 and at day if set to 2

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6262 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2013-07-30 19:32:49 +00:00
parent 8f5ac3a935
commit 64f7d6e616
3 changed files with 31 additions and 2 deletions
+18
View File
@@ -3326,6 +3326,8 @@ UINT16 SelectStandardArmyGun( UINT8 uiGunLevel, INT8 bSoldierClass )
// choose one the of the possible gun choices
usGunIndex = -1;
BOOLEAN isnight = NightTime();
while (usGunIndex == -1)
{
uiChoice = Random(pGunChoiceTable[ uiGunLevel ].ubChoices);
@@ -3357,6 +3359,10 @@ UINT16 SelectStandardArmyGun( UINT8 uiGunLevel, INT8 bSoldierClass )
{
usGunIndex = pGunChoiceTable[ uiGunLevel ].bItemNo[ i ];
// Flugente: ignore this item if we aren't allowed to pick it at this time of day
if ( ( isnight && Item[usGunIndex].usItemChoiceTimeSetting == 1 ) || ( !isnight && Item[usGunIndex].usItemChoiceTimeSetting == 2 ) )
continue;
if (!ItemIsLegal(usGunIndex))
usGunIndex = -1;
else
@@ -3440,6 +3446,8 @@ UINT16 PickARandomItem(UINT8 typeIndex, INT8 bSoldierClass, UINT8 maxCoolness, B
if ( gArmyItemChoices[bSoldierClass][ typeIndex ].ubChoices <= 0 )
return 0;
BOOLEAN isnight = NightTime();
// check up to 10 times for an item with a matching coolness
for (int i=0; i < 10;i++)
{
@@ -3459,6 +3467,10 @@ UINT16 PickARandomItem(UINT8 typeIndex, INT8 bSoldierClass, UINT8 maxCoolness, B
}
usItem = gArmyItemChoices[bSoldierClass][ typeIndex ].bItemNo[ uiChoice ];
// Flugente: ignore this item if we aren't allowed to pick it at this time of day
if ( ( isnight && Item[usItem].usItemChoiceTimeSetting == 1 ) || ( !isnight && Item[usItem].usItemChoiceTimeSetting == 2 ) )
continue;
// Flugente: random items
UINT16 newitemfromrandom = 0;
if ( GetItemFromRandomItem(usItem, &newitemfromrandom) )
@@ -3532,6 +3544,8 @@ UINT16 PickARandomAttachment(UINT8 typeIndex, INT8 bSoldierClass, UINT16 usBaseI
if ( gArmyItemChoices[bSoldierClass][ typeIndex ].ubChoices <= 0 )
return 0;
BOOLEAN isnight = NightTime();
// check up to 10 times for an item with a matching coolness
for (int i=0; i < 50; i++)
{
@@ -3542,6 +3556,10 @@ UINT16 PickARandomAttachment(UINT8 typeIndex, INT8 bSoldierClass, UINT16 usBaseI
uiChoice = Random(gArmyItemChoices[bSoldierClass][ typeIndex ].ubChoices);
usItem = gArmyItemChoices[bSoldierClass][ typeIndex ].bItemNo[ uiChoice ];
// Flugente: ignore this item if we aren't allowed to pick it at this time of day
if ( ( isnight && Item[usItem].usItemChoiceTimeSetting == 1 ) || ( !isnight && Item[usItem].usItemChoiceTimeSetting == 2 ) )
continue;
BOOLEAN fDefaultAttachment = FALSE;
for(UINT8 cnt = 0; cnt < MAX_DEFAULT_ATTACHMENTS; cnt++){
if(Item[usBaseItem].defaultattachments[cnt] == 0)