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)
+4 -1
View File
@@ -1104,7 +1104,7 @@ typedef struct
FLOAT projectionfactor;
BOOLEAN speeddot;
// Flugente FTW 1.2
// Flugente
BOOLEAN barrel; // item can be used on some guns as an exchange barrel
FLOAT usOverheatingCooldownFactor; // every turn/5 seconds, a gun's temperature is lowered by this amount
FLOAT overheatTemperatureModificator; // percentage modifier of heat a shot generates (read from attachments)
@@ -1153,6 +1153,9 @@ typedef struct
// Flugente: range of a flashlight (an item with usFlashLightRange > 0 is deemed a flashlight)
UINT8 usFlashLightRange;
// Flugente: determine wether the AI should pick this item for its choices only at certain times
UINT8 usItemChoiceTimeSetting;
} INVTYPE;
+9 -1
View File
@@ -273,7 +273,8 @@ itemStartElementHandle(void *userData, const XML_Char *name, const XML_Char **at
strcmp(name, "clothestype") == 0 ||
strcmp(name, "randomitem") == 0 ||
strcmp(name, "randomitemcoolnessmodificator") == 0 ||
strcmp(name, "FlashLightRange") == 0 ))
strcmp(name, "FlashLightRange") == 0 ||
strcmp(name, "ItemChoiceTimeSetting") == 0 ))
{
pData->curElement = ELEMENT_PROPERTY;
//DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("itemStartElementHandle: going into element, name = %s",name) );
@@ -1412,6 +1413,12 @@ itemEndElementHandle(void *userData, const XML_Char *name)
pData->curElement = ELEMENT;
pData->curItem.usFlashLightRange = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ItemChoiceTimeSetting") == 0)
{
pData->curElement = ELEMENT;
// no nonsense, only values between 0 and + 2
pData->curItem.usItemChoiceTimeSetting = min(2, max(0, (UINT8) atol(pData->szCharData) ) );
}
pData->maxReadDepth--;
}
@@ -2050,6 +2057,7 @@ BOOLEAN WriteItemStats()
FilePrintf(hFile,"\t\t<randomitem>%d</randomitem>\r\n", Item[cnt].randomitem );
FilePrintf(hFile,"\t\t<randomitemcoolnessmodificator>%d</randomitemcoolnessmodificator>\r\n", Item[cnt].randomitemcoolnessmodificator );
FilePrintf(hFile,"\t\t<FlashLightRange>%d</FlashLightRange>\r\n", Item[cnt].usFlashLightRange );
FilePrintf(hFile,"\t\t<ItemChoiceTimeSetting>%d</ItemChoiceTimeSetting>\r\n", Item[cnt].usItemChoiceTimeSetting );
FilePrintf(hFile,"\t</ITEM>\r\n");
}