ADD_SMOKE_AFTER_EXPLOSION option:

- use default item SMOKE_GRENADE (151) if it's available
- search for first smoke grenade if default item is not grenade
- check that correct smoke grenade was found

Also added new functions:
- ItemIsHandGrenade to check if item is hand grenade
- GetFirstHandGrenadeOfType to find first item which is hand grenade of selected type
- GetHandGrenadeOfType same as GetFirstHandGrenadeOfType, but first check if provided default item is hand grenade of needed type

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9156 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2021-08-27 17:30:27 +00:00
parent 1828cf252b
commit a8c2fa6788
3 changed files with 61 additions and 5 deletions
+49
View File
@@ -12827,6 +12827,55 @@ UINT16 GetFirstExplosiveOfType(UINT16 expType)
return 0;
}
// sevenfm: same as GetFirstExplosiveOfType, but check only hand grenades
UINT16 GetFirstHandGrenadeOfType(UINT16 expType)
{
for (UINT16 i = 0; i < gMAXITEMS_READ; i++)
{
if (ItemIsHandGrenade(i) &&
Item[i].ubCoolness > 0 &&
Explosive[Item[i].ubClassIndex].ubType == expType)
return i;
}
return 0;
}
// sevenfm: use to substitute default item with first matching if needed
UINT16 GetHandGrenadeOfType(UINT16 usDefaultItem, UINT16 usType)
{
UINT16 usSmokeItem = usDefaultItem;
if (usSmokeItem > 0 &&
ItemIsHandGrenade(usSmokeItem) &&
Item[usSmokeItem].ubCoolness > 0 &&
Explosive[Item[usSmokeItem].ubClassIndex].ubType == usType)
return usSmokeItem;
usSmokeItem = GetFirstHandGrenadeOfType(EXPLOSV_SMOKE);
if (usSmokeItem > 0 &&
ItemIsHandGrenade(usSmokeItem) &&
Item[usSmokeItem].ubCoolness > 0 &&
Explosive[Item[usSmokeItem].ubClassIndex].ubType == usType)
return usSmokeItem;
return 0;
}
// sevenfm: check if item is valid hand grenade
BOOLEAN ItemIsHandGrenade(UINT16 usItem)
{
if (usItem > 0 &&
Item[usItem].usItemClass == IC_GRENADE &&
Item[usItem].ubCursor == TOSSCURS)
{
return TRUE;
}
return FALSE;
}
// WDS - Smart goggle switching
OBJECTTYPE* FindSunGogglesInInv( SOLDIERTYPE * pSoldier, INT8 * bSlot, BOOLEAN * isAttach, BOOLEAN searchAllInventory )
{