mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
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:
@@ -3326,6 +3326,8 @@ UINT16 SelectStandardArmyGun( UINT8 uiGunLevel, INT8 bSoldierClass )
|
|||||||
// choose one the of the possible gun choices
|
// choose one the of the possible gun choices
|
||||||
usGunIndex = -1;
|
usGunIndex = -1;
|
||||||
|
|
||||||
|
BOOLEAN isnight = NightTime();
|
||||||
|
|
||||||
while (usGunIndex == -1)
|
while (usGunIndex == -1)
|
||||||
{
|
{
|
||||||
uiChoice = Random(pGunChoiceTable[ uiGunLevel ].ubChoices);
|
uiChoice = Random(pGunChoiceTable[ uiGunLevel ].ubChoices);
|
||||||
@@ -3357,6 +3359,10 @@ UINT16 SelectStandardArmyGun( UINT8 uiGunLevel, INT8 bSoldierClass )
|
|||||||
{
|
{
|
||||||
usGunIndex = pGunChoiceTable[ uiGunLevel ].bItemNo[ i ];
|
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))
|
if (!ItemIsLegal(usGunIndex))
|
||||||
usGunIndex = -1;
|
usGunIndex = -1;
|
||||||
else
|
else
|
||||||
@@ -3440,6 +3446,8 @@ UINT16 PickARandomItem(UINT8 typeIndex, INT8 bSoldierClass, UINT8 maxCoolness, B
|
|||||||
if ( gArmyItemChoices[bSoldierClass][ typeIndex ].ubChoices <= 0 )
|
if ( gArmyItemChoices[bSoldierClass][ typeIndex ].ubChoices <= 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
BOOLEAN isnight = NightTime();
|
||||||
|
|
||||||
// check up to 10 times for an item with a matching coolness
|
// check up to 10 times for an item with a matching coolness
|
||||||
for (int i=0; i < 10;i++)
|
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 ];
|
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
|
// Flugente: random items
|
||||||
UINT16 newitemfromrandom = 0;
|
UINT16 newitemfromrandom = 0;
|
||||||
if ( GetItemFromRandomItem(usItem, &newitemfromrandom) )
|
if ( GetItemFromRandomItem(usItem, &newitemfromrandom) )
|
||||||
@@ -3532,6 +3544,8 @@ UINT16 PickARandomAttachment(UINT8 typeIndex, INT8 bSoldierClass, UINT16 usBaseI
|
|||||||
if ( gArmyItemChoices[bSoldierClass][ typeIndex ].ubChoices <= 0 )
|
if ( gArmyItemChoices[bSoldierClass][ typeIndex ].ubChoices <= 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
BOOLEAN isnight = NightTime();
|
||||||
|
|
||||||
// check up to 10 times for an item with a matching coolness
|
// check up to 10 times for an item with a matching coolness
|
||||||
for (int i=0; i < 50; i++)
|
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);
|
uiChoice = Random(gArmyItemChoices[bSoldierClass][ typeIndex ].ubChoices);
|
||||||
usItem = gArmyItemChoices[bSoldierClass][ typeIndex ].bItemNo[ uiChoice ];
|
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;
|
BOOLEAN fDefaultAttachment = FALSE;
|
||||||
for(UINT8 cnt = 0; cnt < MAX_DEFAULT_ATTACHMENTS; cnt++){
|
for(UINT8 cnt = 0; cnt < MAX_DEFAULT_ATTACHMENTS; cnt++){
|
||||||
if(Item[usBaseItem].defaultattachments[cnt] == 0)
|
if(Item[usBaseItem].defaultattachments[cnt] == 0)
|
||||||
|
|||||||
@@ -1104,7 +1104,7 @@ typedef struct
|
|||||||
FLOAT projectionfactor;
|
FLOAT projectionfactor;
|
||||||
BOOLEAN speeddot;
|
BOOLEAN speeddot;
|
||||||
|
|
||||||
// Flugente FTW 1.2
|
// Flugente
|
||||||
BOOLEAN barrel; // item can be used on some guns as an exchange barrel
|
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 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)
|
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)
|
// Flugente: range of a flashlight (an item with usFlashLightRange > 0 is deemed a flashlight)
|
||||||
UINT8 usFlashLightRange;
|
UINT8 usFlashLightRange;
|
||||||
|
|
||||||
|
// Flugente: determine wether the AI should pick this item for its choices only at certain times
|
||||||
|
UINT8 usItemChoiceTimeSetting;
|
||||||
|
|
||||||
} INVTYPE;
|
} INVTYPE;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+9
-1
@@ -273,7 +273,8 @@ itemStartElementHandle(void *userData, const XML_Char *name, const XML_Char **at
|
|||||||
strcmp(name, "clothestype") == 0 ||
|
strcmp(name, "clothestype") == 0 ||
|
||||||
strcmp(name, "randomitem") == 0 ||
|
strcmp(name, "randomitem") == 0 ||
|
||||||
strcmp(name, "randomitemcoolnessmodificator") == 0 ||
|
strcmp(name, "randomitemcoolnessmodificator") == 0 ||
|
||||||
strcmp(name, "FlashLightRange") == 0 ))
|
strcmp(name, "FlashLightRange") == 0 ||
|
||||||
|
strcmp(name, "ItemChoiceTimeSetting") == 0 ))
|
||||||
{
|
{
|
||||||
pData->curElement = ELEMENT_PROPERTY;
|
pData->curElement = ELEMENT_PROPERTY;
|
||||||
//DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("itemStartElementHandle: going into element, name = %s",name) );
|
//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->curElement = ELEMENT;
|
||||||
pData->curItem.usFlashLightRange = (UINT8) atol(pData->szCharData);
|
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--;
|
pData->maxReadDepth--;
|
||||||
}
|
}
|
||||||
@@ -2050,6 +2057,7 @@ BOOLEAN WriteItemStats()
|
|||||||
FilePrintf(hFile,"\t\t<randomitem>%d</randomitem>\r\n", Item[cnt].randomitem );
|
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<randomitemcoolnessmodificator>%d</randomitemcoolnessmodificator>\r\n", Item[cnt].randomitemcoolnessmodificator );
|
||||||
FilePrintf(hFile,"\t\t<FlashLightRange>%d</FlashLightRange>\r\n", Item[cnt].usFlashLightRange );
|
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");
|
FilePrintf(hFile,"\t</ITEM>\r\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user