From fccef1faea0e087492d69269e4370b398d64ffe2 Mon Sep 17 00:00:00 2001 From: Overhaul Date: Sat, 18 Aug 2007 19:03:20 +0000 Subject: [PATCH] Fix for AI seeking climb point in toxic gas Fix for civilians trying to climb the roof to seek noise Fix for punching and stabbing Transparent change: Gave names to anonymous structs in OBJECTTYPE git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1225 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Editor/Editor Taskbar Utils.cpp | 20 +- Editor/EditorItems.cpp | 74 +-- Editor/EditorMercs.cpp | 2 +- Editor/Item Statistics.cpp | 186 +++---- Editor/Sector Summary.cpp | 22 +- Laptop/personnel.cpp | 22 +- Strategic/Assignments.cpp | 18 +- Strategic/Auto Resolve.cpp | 10 +- .../Map Screen Interface Map Inventory.cpp | 22 +- Strategic/Queen Command.cpp | 5 +- Strategic/Strategic Event Handler.cpp | 20 +- Strategic/Strategic Movement.cpp | 8 +- Strategic/mapscreen.cpp | 2 +- Strategic/strategicmap.cpp | 13 +- Tactical/Arms Dealer Init.cpp | 32 +- Tactical/ArmsDealerInvInit.cpp | 4 +- Tactical/Drugs And Alcohol.cpp | 6 +- Tactical/Handle Items.cpp | 71 +-- Tactical/Interface Dialogue.cpp | 4 +- Tactical/Interface Items.cpp | 92 ++-- Tactical/Interface Panels.cpp | 6 +- Tactical/Interface Utils.cpp | 4 +- Tactical/Inventory Choosing.cpp | 16 +- Tactical/Item Types.h | 44 +- Tactical/Items.cpp | 512 +++++++++--------- Tactical/Items.h | 1 + Tactical/Keys.cpp | 2 +- Tactical/LOS.cpp | 38 +- Tactical/Merc Hiring.cpp | 2 +- Tactical/Militia Control.cpp | 14 +- Tactical/Points.cpp | 12 +- Tactical/Rotting Corpses.cpp | 4 +- Tactical/ShopKeeper Interface.cpp | 72 +-- Tactical/SkillCheck.cpp | 2 +- Tactical/Soldier Add.cpp | 4 +- Tactical/Soldier Ani.cpp | 2 +- Tactical/Soldier Control.cpp | 12 +- Tactical/Soldier Create.cpp | 6 +- Tactical/Soldier Init List.cpp | 16 +- Tactical/Soldier Profile.cpp | 4 +- Tactical/Spread Burst.cpp | 2 +- Tactical/Tactical Save.cpp | 6 +- Tactical/Turn Based Input.cpp | 36 +- Tactical/UI Cursors.cpp | 12 +- Tactical/Weapons.cpp | 86 +-- Tactical/World Items.cpp | 18 +- Tactical/bullets.cpp | 2 +- Tactical/opplist.cpp | 14 +- TacticalAI/AIUtils.cpp | 4 +- TacticalAI/Attacks.cpp | 28 +- TacticalAI/CreatureDecideAction.cpp | 4 +- TacticalAI/DecideAction.cpp | 31 +- TacticalAI/FindLocations.cpp | 18 +- TacticalAI/NPC.cpp | 38 +- TileEngine/Buildings.cpp | 7 +- TileEngine/Buildings.h | 2 +- TileEngine/Explosion Control.cpp | 74 +-- TileEngine/physics.cpp | 8 +- TileEngine/pits.cpp | 8 +- ja2_2005Express.vcproj | 4 +- 60 files changed, 921 insertions(+), 887 deletions(-) diff --git a/Editor/Editor Taskbar Utils.cpp b/Editor/Editor Taskbar Utils.cpp index d4f97481..0a22df46 100644 --- a/Editor/Editor Taskbar Utils.cpp +++ b/Editor/Editor Taskbar Utils.cpp @@ -704,27 +704,27 @@ void BuildTriggerName( OBJECTTYPE *pItem, STR16 szItemName ) { if( pItem->usItem == SWITCH ) { - if( pItem->bFrequency == PANIC_FREQUENCY ) + if( pItem->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY ) swprintf( szItemName, L"Panic Trigger1" ); - else if( pItem->bFrequency == PANIC_FREQUENCY_2 ) + else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY_2 ) swprintf( szItemName, L"Panic Trigger2" ); - else if( pItem->bFrequency == PANIC_FREQUENCY_3 ) + else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY_3 ) swprintf( szItemName, L"Panic Trigger3" ); else - swprintf( szItemName, L"Trigger%d", pItem->bFrequency - 50 ); + swprintf( szItemName, L"Trigger%d", pItem->ItemData.Trigger.BombTrigger.bFrequency - 50 ); } else { //action item - if( pItem->bDetonatorType == BOMB_PRESSURE ) + if( pItem->ItemData.Trigger.bDetonatorType == BOMB_PRESSURE ) swprintf( szItemName, L"Pressure Action" ); - else if( pItem->bFrequency == PANIC_FREQUENCY ) + else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY ) swprintf( szItemName, L"Panic Action1" ); - else if( pItem->bFrequency == PANIC_FREQUENCY_2 ) + else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY_2 ) swprintf( szItemName, L"Panic Action2" ); - else if( pItem->bFrequency == PANIC_FREQUENCY_3 ) + else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY_3 ) swprintf( szItemName, L"Panic Action3" ); else - swprintf( szItemName, L"Action%d", pItem->bFrequency - 50 ); + swprintf( szItemName, L"Action%d", pItem->ItemData.Trigger.BombTrigger.bFrequency - 50 ); } } @@ -818,7 +818,7 @@ void RenderSelectedItemBlownUp() } else if( Item[ gpItem->usItem ].usItemClass == IC_KEY ) { - swprintf( szItemName, L"%S", LockTable[ gpItem->ubKeyID ].ubEditorName ); + swprintf( szItemName, L"%S", LockTable[ gpItem->ItemData.Key.ubKeyID ].ubEditorName ); } else { diff --git a/Editor/EditorItems.cpp b/Editor/EditorItems.cpp index be23d44e..b36e2b0e 100644 --- a/Editor/EditorItems.cpp +++ b/Editor/EditorItems.cpp @@ -844,11 +844,11 @@ void AddSelectedItemToWorld( INT16 sGridNo ) case MONEY: case SILVER: case GOLD: - tempObject.bStatus[0] = 100; - tempObject.uiMoneyAmount = 100 + Random( 19901 ); + tempObject.ItemData.Money.bMoneyStatus = 100; + tempObject.ItemData.Money.uiMoneyAmount = 100 + Random( 19901 ); break; case OWNERSHIP: - tempObject.ubOwnerProfile = NO_PROFILE; + tempObject.ItemData.Owner.ubOwnerProfile = NO_PROFILE; bVisibility = BURIED; break; case SWITCH: @@ -857,39 +857,39 @@ void AddSelectedItemToWorld( INT16 sGridNo ) return; } bVisibility = BURIED; - tempObject.bStatus[0] = 100; - tempObject.ubBombOwner = 1; + tempObject.ItemData.Trigger.bBombStatus = 100; + tempObject.ItemData.Trigger.ubBombOwner = 1; if( eInfo.sSelItemIndex < 2 ) - tempObject.bFrequency = PANIC_FREQUENCY; + tempObject.ItemData.Trigger.BombTrigger.bFrequency = PANIC_FREQUENCY; else if( eInfo.sSelItemIndex < 4 ) - tempObject.bFrequency = PANIC_FREQUENCY_2; + tempObject.ItemData.Trigger.BombTrigger.bFrequency = PANIC_FREQUENCY_2; else if( eInfo.sSelItemIndex < 6 ) - tempObject.bFrequency = PANIC_FREQUENCY_3; + tempObject.ItemData.Trigger.BombTrigger.bFrequency = PANIC_FREQUENCY_3; else - tempObject.bFrequency = (INT8)(FIRST_MAP_PLACED_FREQUENCY + (eInfo.sSelItemIndex-4) / 2); + tempObject.ItemData.Trigger.BombTrigger.bFrequency = (INT8)(FIRST_MAP_PLACED_FREQUENCY + (eInfo.sSelItemIndex-4) / 2); usFlags |= WORLD_ITEM_ARMED_BOMB; break; case ACTION_ITEM: bVisibility = BURIED; - tempObject.bStatus[0] = 100; - tempObject.ubBombOwner = 1; + tempObject.ItemData.Trigger.bBombStatus = 100; + tempObject.ItemData.Trigger.ubBombOwner = 1; tempObject.bTrap = gbDefaultBombTrapLevel; if( eInfo.sSelItemIndex < PRESSURE_ACTION_ID ) { - tempObject.bDetonatorType = BOMB_REMOTE; + tempObject.ItemData.Trigger.bDetonatorType = BOMB_REMOTE; if( eInfo.sSelItemIndex < 2 ) - tempObject.bFrequency = PANIC_FREQUENCY; + tempObject.ItemData.Trigger.BombTrigger.bFrequency = PANIC_FREQUENCY; else if( eInfo.sSelItemIndex < 4 ) - tempObject.bFrequency = PANIC_FREQUENCY_2; + tempObject.ItemData.Trigger.BombTrigger.bFrequency = PANIC_FREQUENCY_2; else if( eInfo.sSelItemIndex < 6 ) - tempObject.bFrequency = PANIC_FREQUENCY_3; + tempObject.ItemData.Trigger.BombTrigger.bFrequency = PANIC_FREQUENCY_3; else - tempObject.bFrequency = (INT8)(FIRST_MAP_PLACED_FREQUENCY + (eInfo.sSelItemIndex-4) / 2); + tempObject.ItemData.Trigger.BombTrigger.bFrequency = (INT8)(FIRST_MAP_PLACED_FREQUENCY + (eInfo.sSelItemIndex-4) / 2); } else { - tempObject.bDetonatorType = BOMB_PRESSURE; - tempObject.bDelay = 0; + tempObject.ItemData.Trigger.bDetonatorType = BOMB_PRESSURE; + tempObject.ItemData.Trigger.BombTrigger.bDelay = 0; } ChangeActionItem( &tempObject, gbActionItemIndex ); tempObject.fFlags |= OBJECT_ARMED_BOMB; @@ -916,26 +916,26 @@ void AddSelectedItemToWorld( INT16 sGridNo ) { if (Random( 2 )) { - pObject->ubShotsLeft[0] = Magazine[ pItem->ubClassIndex ].ubMagSize; + pObject->ItemData.Ammo.ubShotsLeft[0] = Magazine[ pItem->ubClassIndex ].ubMagSize; } else { - pObject->ubShotsLeft[0] = (UINT8) Random( Magazine[ pItem->ubClassIndex ].ubMagSize ); + pObject->ItemData.Ammo.ubShotsLeft[0] = (UINT8) Random( Magazine[ pItem->ubClassIndex ].ubMagSize ); } } else { - pObject->bStatus[0] = (INT8)(70 + Random( 26 )); + pObject->ItemData.Generic.bStatus[0] = (INT8)(70 + Random( 26 )); } if( pItem->usItemClass & IC_GUN ) { if ( pObject->usItem == ROCKET_LAUNCHER ) { - pObject->ubGunShotsLeft = 1; + pObject->ItemData.Gun.ubGunShotsLeft = 1; } else { - pObject->ubGunShotsLeft = (UINT8)(Random( Weapon[ pObject->usItem ].ubMagSize )); + pObject->ItemData.Gun.ubGunShotsLeft = (UINT8)(Random( Weapon[ pObject->usItem ].ubMagSize )); } } @@ -1054,9 +1054,9 @@ void DeleteSelectedItem() //remove the item if( gWorldItems[ gpItemPool->iItemIndex ].o.usItem == ACTION_ITEM ) { - if( gWorldItems[ gpItemPool->iItemIndex ].o.bActionValue == ACTION_ITEM_SMALL_PIT ) + if( gWorldItems[ gpItemPool->iItemIndex ].o.ItemData.Trigger.bActionValue == ACTION_ITEM_SMALL_PIT ) Remove3X3Pit( gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); - else if( gWorldItems[ gpItemPool->iItemIndex ].o.bActionValue == ACTION_ITEM_LARGE_PIT ) + else if( gWorldItems[ gpItemPool->iItemIndex ].o.ItemData.Trigger.bActionValue == ACTION_ITEM_LARGE_PIT ) Remove5X5Pit( gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); } if( gpEditingItemPool == gpItemPool ) @@ -1295,7 +1295,7 @@ void SelectNextKeyOfType( UINT8 ubKeyID ) while( gpItemPool ) { pObject = &gWorldItems[ gpItemPool->iItemIndex ].o; - if( Item[ pObject->usItem ].usItemClass == IC_KEY && pObject->ubKeyID == ubKeyID ) + if( Item[ pObject->usItem ].usItemClass == IC_KEY && pObject->ItemData.Key.ubKeyID == ubKeyID ) { SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); CenterScreenAtMapIndex( gsItemGridNo ); @@ -1314,7 +1314,7 @@ void SelectNextKeyOfType( UINT8 ubKeyID ) while( gpItemPool ) { pObject = &gWorldItems[ gpItemPool->iItemIndex ].o; - if( Item[ pObject->usItem ].usItemClass == IC_KEY && pObject->ubKeyID == ubKeyID ) + if( Item[ pObject->usItem ].usItemClass == IC_KEY && pObject->ItemData.Key.ubKeyID == ubKeyID ) { SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); CenterScreenAtMapIndex( gsItemGridNo ); @@ -1332,7 +1332,7 @@ void SelectNextKeyOfType( UINT8 ubKeyID ) while( gpItemPool ) { pObject = &gWorldItems[ gpItemPool->iItemIndex ].o; - if( Item[ pObject->usItem ].usItemClass == IC_KEY && pObject->ubKeyID == ubKeyID ) + if( Item[ pObject->usItem ].usItemClass == IC_KEY && pObject->ItemData.Key.ubKeyID == ubKeyID ) { SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); CenterScreenAtMapIndex( gsItemGridNo ); @@ -1359,7 +1359,7 @@ void SelectNextTriggerWithFrequency( UINT16 usItem, INT8 bFrequency ) while( gpItemPool ) { pObject = &gWorldItems[ gpItemPool->iItemIndex ].o; - if( pObject->usItem == usItem && pObject->bFrequency == bFrequency ) + if( pObject->usItem == usItem && pObject->ItemData.Trigger.BombTrigger.bFrequency == bFrequency ) { SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); CenterScreenAtMapIndex( gsItemGridNo ); @@ -1378,7 +1378,7 @@ void SelectNextTriggerWithFrequency( UINT16 usItem, INT8 bFrequency ) while( gpItemPool ) { pObject = &gWorldItems[ gpItemPool->iItemIndex ].o; - if( pObject->usItem == usItem && pObject->bFrequency == bFrequency ) + if( pObject->usItem == usItem && pObject->ItemData.Trigger.BombTrigger.bFrequency == bFrequency ) { SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); CenterScreenAtMapIndex( gsItemGridNo ); @@ -1396,7 +1396,7 @@ void SelectNextTriggerWithFrequency( UINT16 usItem, INT8 bFrequency ) while( gpItemPool ) { pObject = &gWorldItems[ gpItemPool->iItemIndex ].o; - if( pObject->usItem == usItem && pObject->bFrequency == bFrequency ) + if( pObject->usItem == usItem && pObject->ItemData.Trigger.BombTrigger.bFrequency == bFrequency ) { SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); CenterScreenAtMapIndex( gsItemGridNo ); @@ -1423,7 +1423,7 @@ void SelectNextPressureAction() while( gpItemPool ) { pObject = &gWorldItems[ gpItemPool->iItemIndex ].o; - if( pObject->usItem == ACTION_ITEM && pObject->bDetonatorType == BOMB_PRESSURE ) + if( pObject->usItem == ACTION_ITEM && pObject->ItemData.Trigger.bDetonatorType == BOMB_PRESSURE ) { SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); CenterScreenAtMapIndex( gsItemGridNo ); @@ -1442,7 +1442,7 @@ void SelectNextPressureAction() while( gpItemPool ) { pObject = &gWorldItems[ gpItemPool->iItemIndex ].o; - if( pObject->usItem == ACTION_ITEM && pObject->bDetonatorType == BOMB_PRESSURE ) + if( pObject->usItem == ACTION_ITEM && pObject->ItemData.Trigger.bDetonatorType == BOMB_PRESSURE ) { SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); CenterScreenAtMapIndex( gsItemGridNo ); @@ -1460,7 +1460,7 @@ void SelectNextPressureAction() while( gpItemPool ) { pObject = &gWorldItems[ gpItemPool->iItemIndex ].o; - if( pObject->usItem == ACTION_ITEM && pObject->bDetonatorType == BOMB_PRESSURE ) + if( pObject->usItem == ACTION_ITEM && pObject->ItemData.Trigger.bDetonatorType == BOMB_PRESSURE ) { SpecifyItemToEdit( pObject, gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); CenterScreenAtMapIndex( gsItemGridNo ); @@ -1508,7 +1508,7 @@ UINT16 CountNumberOfItemsWithFrequency( UINT16 usItem, INT8 bFrequency ) while( pItemPool ) { if( gWorldItems[ pItemPool->iItemIndex ].o.usItem == usItem && - gWorldItems[ pItemPool->iItemIndex ].o.bFrequency == bFrequency ) + gWorldItems[ pItemPool->iItemIndex ].o.ItemData.Trigger.BombTrigger.bFrequency == bFrequency ) { num++; } @@ -1531,7 +1531,7 @@ UINT16 CountNumberOfPressureActionsInWorld() while( pItemPool ) { if( gWorldItems[ pItemPool->iItemIndex ].o.usItem == ACTION_ITEM && - gWorldItems[ pItemPool->iItemIndex ].o.bDetonatorType == BOMB_PRESSURE ) + gWorldItems[ pItemPool->iItemIndex ].o.ItemData.Trigger.bDetonatorType == BOMB_PRESSURE ) { num++; } @@ -1592,7 +1592,7 @@ UINT16 CountNumberOfKeysOfTypeInWorld( UINT8 ubKeyID ) { if( Item[ gWorldItems[ pItemPool->iItemIndex ].o.usItem ].usItemClass == IC_KEY ) { - if( gWorldItems[ pItemPool->iItemIndex ].o.ubKeyID == ubKeyID ) + if( gWorldItems[ pItemPool->iItemIndex ].o.ItemData.Key.ubKeyID == ubKeyID ) { num++; } diff --git a/Editor/EditorMercs.cpp b/Editor/EditorMercs.cpp index fb1a3919..7a3658f6 100644 --- a/Editor/EditorMercs.cpp +++ b/Editor/EditorMercs.cpp @@ -2767,7 +2767,7 @@ void AddNewItemToSelectedMercsInventory( BOOLEAN fCreate ) //randomize the status on non-ammo items. if( !(Item[ gpSelected->pDetailedPlacement->Inv[ gbMercSlotTypes[ gbCurrSelect ] ].usItem ].usItemClass & IC_AMMO) ) - gpSelected->pDetailedPlacement->Inv[ gbMercSlotTypes[ gbCurrSelect ] ].bStatus[0] = (INT8)(80 + Random( 21 )); + gpSelected->pDetailedPlacement->Inv[ gbMercSlotTypes[ gbCurrSelect ] ].ItemData.Generic.bStatus[0] = (INT8)(80 + Random( 21 )); if( gusMercsNewItemIndex ) { diff --git a/Editor/Item Statistics.cpp b/Editor/Item Statistics.cpp index a517aa7a..961f9ce4 100644 --- a/Editor/Item Statistics.cpp +++ b/Editor/Item Statistics.cpp @@ -81,9 +81,9 @@ const STR16 GetActionItemName( OBJECTTYPE *pItem ) { if( !pItem || pItem->usItem != ACTION_ITEM ) return NULL; - if( pItem->bActionValue != ACTION_ITEM_BLOW_UP ) + if( pItem->ItemData.Trigger.bActionValue != ACTION_ITEM_BLOW_UP ) { - switch( pItem->bActionValue ) + switch( pItem->ItemData.Trigger.bActionValue ) { case ACTION_ITEM_OPEN_DOOR: return gszActionItemDesc[ ACTIONITEM_OPEN ]; case ACTION_ITEM_CLOSE_DOOR: return gszActionItemDesc[ ACTIONITEM_CLOSE ]; @@ -111,7 +111,7 @@ const STR16 GetActionItemName( OBJECTTYPE *pItem ) default: return NULL; } } - else switch( pItem->usBombItem ) + else switch( pItem->ItemData.Trigger.usBombItem ) { case STUN_GRENADE: return gszActionItemDesc[ ACTIONITEM_STUN ]; case SMOKE_GRENADE: return gszActionItemDesc[ ACTIONITEM_SMOKE ]; @@ -535,7 +535,7 @@ void UpdateItemStatsPanel() case EDITING_TRIGGERS: mprintf( iScreenWidthOffset + 512, 2 * iScreenHeightOffset + 369, L"Trap Level"); mprintf( iScreenWidthOffset + 512, 2 * iScreenHeightOffset + 389, L"Tolerance" ); - if( gpEditingItemPool && gpItem->bFrequency >= PANIC_FREQUENCY_3 && gpItem->bFrequency <= PANIC_FREQUENCY ) + if( gpEditingItemPool && gpItem->ItemData.Trigger.BombTrigger.bFrequency >= PANIC_FREQUENCY_3 && gpItem->ItemData.Trigger.BombTrigger.bFrequency <= PANIC_FREQUENCY ) mprintf( iScreenWidthOffset + 500, 2 * iScreenHeightOffset + 407, L"Alarm Trigger" ); break; } @@ -644,9 +644,9 @@ void SetupGunGUI() CHAR16 str[20]; INT16 yp; memset( gfAttachment, 0, NUM_ATTACHMENT_BUTTONS ); - swprintf( str, L"%d", gpItem->bGunStatus ); + swprintf( str, L"%d", gpItem->ItemData.Gun.bGunStatus ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 380, 25, 15, MSYS_PRIORITY_NORMAL, str, 3, INPUTTYPE_NUMERICSTRICT ); - swprintf( str, L"%d", gpItem->ubGunShotsLeft ); + swprintf( str, L"%d", gpItem->ItemData.Gun.ubGunShotsLeft ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 400, 25, 15, MSYS_PRIORITY_NORMAL, str, 3, INPUTTYPE_NUMERICSTRICT ); swprintf( str, L"%d", gpItem->bTrap ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 420, 25, 15, MSYS_PRIORITY_NORMAL, str, 2, INPUTTYPE_NUMERICSTRICT ); @@ -761,7 +761,7 @@ void ExtractAndUpdateGunGUI() i = 20 + Random( 81 ); else i = min( i, 100 ); - gpItem->bGunStatus = (INT8)i; + gpItem->ItemData.Gun.bGunStatus = (INT8)i; SetInputFieldStringWithNumericStrictValue( 1, i ); //Update the ammo i = GetNumericStrictValueFromField( 2 ); @@ -769,7 +769,7 @@ void ExtractAndUpdateGunGUI() i = Random( 1 + Weapon[ gpItem->usItem ].ubMagSize ); else i = min( i, Weapon[ gpItem->usItem ].ubMagSize ); - gpItem->ubGunShotsLeft = (UINT8)i; + gpItem->ItemData.Gun.ubGunShotsLeft = (UINT8)i; SetInputFieldStringWithNumericStrictValue( 2, i ); //Update the trap level i = GetNumericStrictValueFromField( 3 ); @@ -833,7 +833,7 @@ void ExtractAndUpdateAmmoGUI() void SetupArmourGUI() { CHAR16 str[20]; - swprintf( str, L"%d", gpItem->bStatus[0] ); + swprintf( str, L"%d", gpItem->ItemData.Generic.bStatus[0] ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 380, 25, 15, MSYS_PRIORITY_NORMAL, str, 3, INPUTTYPE_NUMERICSTRICT ); swprintf( str, L"%d", gpItem->bTrap ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 400, 25, 15, MSYS_PRIORITY_NORMAL, str, 2, INPUTTYPE_NUMERICSTRICT ); @@ -875,7 +875,7 @@ void ExtractAndUpdateArmourGUI() i = 20 + Random( 81 ); else i = min( i, 100 ); - gpItem->bStatus[0] = (INT8)i; + gpItem->ItemData.Generic.bStatus[0] = (INT8)i; SetInputFieldStringWithNumericStrictValue( 1, i ); //Update the trap level i = GetNumericStrictValueFromField( 2 ); @@ -894,7 +894,7 @@ void ExtractAndUpdateArmourGUI() void SetupEquipGUI() { CHAR16 str[20]; - swprintf( str, L"%d", gpItem->bStatus[0] ); + swprintf( str, L"%d", gpItem->ItemData.Generic.bStatus[0] ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 380, 25, 15, MSYS_PRIORITY_NORMAL, str, 3, INPUTTYPE_NUMERICSTRICT ); swprintf( str, L"%d", gpItem->bTrap ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 400, 25, 15, MSYS_PRIORITY_NORMAL, str, 2, INPUTTYPE_NUMERICSTRICT ); @@ -919,7 +919,7 @@ void ExtractAndUpdateEquipGUI() i = 20 + Random( 81 ); else i = min( i, 100 ); - gpItem->bStatus[0] = (INT8)i; + gpItem->ItemData.Generic.bStatus[0] = (INT8)i; SetInputFieldStringWithNumericStrictValue( 1, i ); //Update the trap level i = GetNumericStrictValueFromField( 2 ); @@ -939,7 +939,7 @@ void SetupExplosivesGUI() { CHAR16 str[20]; INT16 yp; - swprintf( str, L"%d", gpItem->bStatus[0] ); + swprintf( str, L"%d", gpItem->ItemData.Generic.bStatus[0] ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 380, 25, 15, MSYS_PRIORITY_NORMAL, str, 3, INPUTTYPE_NUMERICSTRICT ); swprintf( str, L"%d", gpItem->ubNumberOfObjects ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 400, 25, 15, MSYS_PRIORITY_NORMAL, str, 1, INPUTTYPE_NUMERICSTRICT ); @@ -989,7 +989,7 @@ void ExtractAndUpdateExplosivesGUI() i = 20 + Random( 81 ); else i = min( i, 100 ); - gpItem->bStatus[0] = (INT8)i; + gpItem->ItemData.Generic.bStatus[0] = (INT8)i; SetInputFieldStringWithNumericStrictValue( 1, i ); //Update the quantity if( Item[ gpItem->usItem ].ubPerPocket > 1 ) @@ -1001,7 +1001,7 @@ void ExtractAndUpdateExplosivesGUI() i = max( 1, min( i, Item[ gpItem->usItem ].ubPerPocket ) ); gpItem->ubNumberOfObjects = (UINT8)i; SetInputFieldStringWithNumericStrictValue( 2, i ); - CreateItems( gpItem->usItem, gpItem->bStatus[0], gpItem->ubNumberOfObjects, gpItem ); + CreateItems( gpItem->usItem, gpItem->ItemData.Generic.bStatus[0], gpItem->ubNumberOfObjects, gpItem ); } //Update the trap level i = GetNumericStrictValueFromField( 3 ); @@ -1020,7 +1020,7 @@ void ExtractAndUpdateExplosivesGUI() void SetupMoneyGUI() { CHAR16 str[20]; - swprintf( str, L"%d", gpItem->uiMoneyAmount ); + swprintf( str, L"%d", gpItem->ItemData.Money.uiMoneyAmount ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 380, 45, 15, MSYS_PRIORITY_NORMAL, str, 5, INPUTTYPE_NUMERICSTRICT ); if( gpEditingItemPool ) { @@ -1038,8 +1038,8 @@ void ExtractAndUpdateMoneyGUI() i = Random( 20000 ); else i = max( 1, min( i, 20000 ) ); - gpItem->uiMoneyAmount = i; - gpItem->bStatus[0] = 100; + gpItem->ItemData.Money.uiMoneyAmount = i; + gpItem->ItemData.Money.bMoneyStatus = 100; SetInputFieldStringWithNumericStrictValue( 1, i ); if( gpEditingItemPool ) { @@ -1058,10 +1058,10 @@ void RemoveMoneyGUI() void SetupOwnershipGUI() { CHAR16 str[20]; - swprintf( str, L"%d", gpItem->ubOwnerProfile ); + swprintf( str, L"%d", gpItem->ItemData.Owner.ubOwnerProfile ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 380, 25, 15, MSYS_PRIORITY_NORMAL, str, 3, INPUTTYPE_NUMERICSTRICT ); giOwnershipGroupButton = - CreateTextButton( gszCivGroupNames[ gpItem->ubOwnerCivGroup ], SMALLCOMPFONT, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, + CreateTextButton( gszCivGroupNames[ gpItem->ItemData.Owner.ubOwnerCivGroup ], SMALLCOMPFONT, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 415, 80, 25, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, OwnershipGroupButtonCallback ); } @@ -1075,7 +1075,7 @@ void OwnershipGroupButtonCallback( GUI_BUTTON *btn, INT32 reason ) void SetOwnershipGroup( UINT8 ubNewGroup ) { - gpItem->ubOwnerCivGroup = ubNewGroup; + gpItem->ItemData.Owner.ubOwnerCivGroup = ubNewGroup; SpecifyButtonText( giOwnershipGroupButton, gszCivGroupNames[ ubNewGroup ] ); } @@ -1088,7 +1088,7 @@ void ExtractAndUpdateOwnershipGUI() i = Random( 0 ); else i = max( 0, min( i, 255 ) ); - gpItem->ubOwnerProfile = (UINT8)i; + gpItem->ItemData.Owner.ubOwnerProfile = (UINT8)i; SetInputFieldStringWithNumericStrictValue( 1, i ); } @@ -1131,7 +1131,7 @@ void SetupActionItemsGUI() { CHAR16 str[4]; STR16 pStr; - swprintf( str, L"%d", gpItem->bStatus[0] ); + swprintf( str, L"%d", gpItem->ItemData.Generic.bStatus[0] ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 365, 25, 15, MSYS_PRIORITY_NORMAL, str, 3, INPUTTYPE_NUMERICSTRICT ); swprintf( str, L"%d", gpItem->bTrap ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 385, 25, 15, MSYS_PRIORITY_NORMAL, str, 2, INPUTTYPE_NUMERICSTRICT ); @@ -1155,7 +1155,7 @@ void ExtractAndUpdateActionItemsGUI() i = 20 + Random( 81 ); else i = min( i, 100 ); - gpItem->bStatus[0] = (INT8)i; + gpItem->ItemData.Generic.bStatus[0] = (INT8)i; SetInputFieldStringWithNumericStrictValue( 1, i ); //Update the trap level i = GetNumericStrictValueFromField( 2 ); @@ -1199,13 +1199,13 @@ void SetupTriggersGUI() CHAR16 str[4]; swprintf( str, L"%d", gpItem->bTrap ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 365, 25, 15, MSYS_PRIORITY_NORMAL, str, 3, INPUTTYPE_NUMERICSTRICT ); - swprintf( str, L"%d", gpItem->ubTolerance ); + swprintf( str, L"%d", gpItem->ItemData.Trigger.Area.ubTolerance ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 385, 25, 15, MSYS_PRIORITY_NORMAL, str, 3, INPUTTYPE_NUMERICSTRICT ); if( gpEditingItemPool ) { swprintf( str, L"%d", 100 - gWorldItems[ gpEditingItemPool->iItemIndex ].ubNonExistChance ); AddTextInputField( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 440, 25, 15, MSYS_PRIORITY_NORMAL, str, 3, INPUTTYPE_NUMERICSTRICT ); - if( gpItem->bFrequency <= PANIC_FREQUENCY && gpItem->bFrequency >= PANIC_FREQUENCY_3 ) + if( gpItem->ItemData.Trigger.BombTrigger.bFrequency <= PANIC_FREQUENCY && gpItem->ItemData.Trigger.BombTrigger.bFrequency >= PANIC_FREQUENCY_3 ) { giAlarmTriggerButton = CreateCheckBoxButton( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 405, "EDITOR//smCheckBox.sti", MSYS_PRIORITY_NORMAL, AlarmTriggerCheckboxCallback ); @@ -1227,7 +1227,7 @@ void ExtractAndUpdateTriggersGUI() i = GetNumericStrictValueFromField( 2 ); i = ( i == -1 ) ? 0 : max( 0, min( i, 99 ) ); - gpItem->ubTolerance = (UINT8)i; + gpItem->ItemData.Trigger.Area.ubTolerance = (UINT8)i; SetInputFieldStringWithNumericStrictValue( 2, i ); if( gpEditingItemPool ) @@ -1241,7 +1241,7 @@ void ExtractAndUpdateTriggersGUI() void RemoveTriggersGUI() { - if( gpEditingItemPool && gpItem->bFrequency <= PANIC_FREQUENCY && gpItem->bFrequency >= PANIC_FREQUENCY_3 ) + if( gpEditingItemPool && gpItem->ItemData.Trigger.BombTrigger.bFrequency <= PANIC_FREQUENCY && gpItem->ItemData.Trigger.BombTrigger.bFrequency >= PANIC_FREQUENCY_3 ) { if( giAlarmTriggerButton != -1 ) { @@ -1276,7 +1276,7 @@ void ToggleAttachment( GUI_BUTTON *btn, INT32 reason ) { gfAttachment[ i ] = TRUE; btn->uiFlags |= BUTTON_CLICKED_ON; - CreateItem( usAttachment, gpItem->bGunStatus, &temp ); + CreateItem( usAttachment, gpItem->ItemData.Gun.bGunStatus, &temp ); AttachObject( NULL, gpItem, &temp ); } else @@ -1303,7 +1303,7 @@ void ToggleCeramicPlates( GUI_BUTTON *btn, INT32 reason ) if( gfCeramicPlates ) { btn->uiFlags |= BUTTON_CLICKED_ON; - CreateItem( CERAMIC_PLATES, gpItem->bStatus[0], &temp ); + CreateItem( CERAMIC_PLATES, gpItem->ItemData.Generic.bStatus[0], &temp ); AttachObject( NULL, gpItem, &temp ); } else @@ -1326,7 +1326,7 @@ void ToggleDetonator( GUI_BUTTON *btn, INT32 reason ) { gfDetonator = TRUE; btn->uiFlags |= BUTTON_CLICKED_ON; - CreateItem( DETONATOR, gpItem->bStatus[0], &temp ); + CreateItem( DETONATOR, gpItem->ItemData.Generic.bStatus[0], &temp ); AttachObject( NULL, gpItem, &temp ); } else @@ -1352,133 +1352,133 @@ void ActionItemCallback( GUI_BUTTON *btn, INT32 reason ) void ChangeActionItem( OBJECTTYPE *pItem, INT8 bActionItemIndex ) { pItem->usItem = ACTION_ITEM; - pItem->bActionValue = ACTION_ITEM_BLOW_UP; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_BLOW_UP; switch( bActionItemIndex ) { case ACTIONITEM_TRIP_KLAXON: - pItem->usBombItem = TRIP_KLAXON; + pItem->ItemData.Trigger.usBombItem = TRIP_KLAXON; break; case ACTIONITEM_FLARE: - pItem->usBombItem = TRIP_FLARE; + pItem->ItemData.Trigger.usBombItem = TRIP_FLARE; break; case ACTIONITEM_TEARGAS: - pItem->usBombItem = TEARGAS_GRENADE; + pItem->ItemData.Trigger.usBombItem = TEARGAS_GRENADE; break; case ACTIONITEM_STUN: - pItem->usBombItem = STUN_GRENADE; + pItem->ItemData.Trigger.usBombItem = STUN_GRENADE; break; case ACTIONITEM_SMOKE: - pItem->usBombItem = SMOKE_GRENADE; + pItem->ItemData.Trigger.usBombItem = SMOKE_GRENADE; break; case ACTIONITEM_MUSTARD: - pItem->usBombItem = MUSTARD_GRENADE; + pItem->ItemData.Trigger.usBombItem = MUSTARD_GRENADE; break; case ACTIONITEM_MINE: - pItem->usBombItem = MINE; + pItem->ItemData.Trigger.usBombItem = MINE; break; case ACTIONITEM_OPEN: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_OPEN_DOOR; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_OPEN_DOOR; break; case ACTIONITEM_CLOSE: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_CLOSE_DOOR; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_CLOSE_DOOR; break; case ACTIONITEM_UNLOCK_DOOR: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_UNLOCK_DOOR; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_UNLOCK_DOOR; break; case ACTIONITEM_TOGGLE_LOCK: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_TOGGLE_LOCK; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_TOGGLE_LOCK; break; case ACTIONITEM_UNTRAP_DOOR: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_UNTRAP_DOOR; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_UNTRAP_DOOR; break; case ACTIONITEM_TOGGLE_PRESSURE_ITEMS: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_TOGGLE_PRESSURE_ITEMS; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_TOGGLE_PRESSURE_ITEMS; break; case ACTIONITEM_SMPIT: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_SMALL_PIT; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_SMALL_PIT; break; case ACTIONITEM_LGPIT: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_LARGE_PIT; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_LARGE_PIT; break; case ACTIONITEM_TOGGLE_DOOR: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_TOGGLE_DOOR; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_TOGGLE_DOOR; break; case ACTIONITEM_TOGGLE_ACTION1: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_TOGGLE_ACTION1; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_TOGGLE_ACTION1; break; case ACTIONITEM_TOGGLE_ACTION2: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_TOGGLE_ACTION2; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_TOGGLE_ACTION2; break; case ACTIONITEM_TOGGLE_ACTION3: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_TOGGLE_ACTION3; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_TOGGLE_ACTION3; break; case ACTIONITEM_TOGGLE_ACTION4: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_TOGGLE_ACTION4; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_TOGGLE_ACTION4; break; case ACTIONITEM_ENTER_BROTHEL: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_ENTER_BROTHEL; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_ENTER_BROTHEL; break; case ACTIONITEM_EXIT_BROTHEL: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_EXIT_BROTHEL; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_EXIT_BROTHEL; break; case ACTIONITEM_KINGPIN_ALARM: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_KINGPIN_ALARM; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_KINGPIN_ALARM; break; case ACTIONITEM_SEX: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_SEX; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_SEX; break; case ACTIONITEM_REVEAL_ROOM: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_REVEAL_ROOM; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_REVEAL_ROOM; break; case ACTIONITEM_LOCAL_ALARM: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_LOCAL_ALARM; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_LOCAL_ALARM; break; case ACTIONITEM_GLOBAL_ALARM: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_GLOBAL_ALARM; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_GLOBAL_ALARM; break; case ACTIONITEM_KLAXON: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_KLAXON; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_KLAXON; break; case ACTIONITEM_SMALL: - pItem->usBombItem = HAND_GRENADE; + pItem->ItemData.Trigger.usBombItem = HAND_GRENADE; break; case ACTIONITEM_MEDIUM: - pItem->usBombItem = TNT; + pItem->ItemData.Trigger.usBombItem = TNT; break; case ACTIONITEM_LARGE: - pItem->usBombItem = C4; + pItem->ItemData.Trigger.usBombItem = C4; break; case ACTIONITEM_MUSEUM_ALARM: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_MUSEUM_ALARM; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_MUSEUM_ALARM; break; case ACTIONITEM_BLOODCAT_ALARM: - pItem->usBombItem = NOTHING; - pItem->bActionValue = ACTION_ITEM_BLOODCAT_ALARM; + pItem->ItemData.Trigger.usBombItem = NOTHING; + pItem->ItemData.Trigger.bActionValue = ACTION_ITEM_BLOODCAT_ALARM; break; case ACTIONITEM_BIG_TEAR_GAS: - pItem->usBombItem = BIG_TEAR_GAS; + pItem->ItemData.Trigger.usBombItem = BIG_TEAR_GAS; break; } @@ -1494,9 +1494,9 @@ void UpdateActionItem( INT8 bActionItemIndex ) //If the previous item was a pit, remove it before changing it if( gpItem->usItem == ACTION_ITEM ) { - if( gpItem->bActionValue == ACTION_ITEM_SMALL_PIT ) + if( gpItem->ItemData.Trigger.bActionValue == ACTION_ITEM_SMALL_PIT ) Remove3X3Pit( gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); - else if( gpItem->bActionValue == ACTION_ITEM_LARGE_PIT ) + else if( gpItem->ItemData.Trigger.bActionValue == ACTION_ITEM_LARGE_PIT ) Remove5X5Pit( gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); } @@ -1506,9 +1506,9 @@ void UpdateActionItem( INT8 bActionItemIndex ) //If the new item is a pit, add it so we can see how it looks. if( gpItem->usItem == ACTION_ITEM ) { - if( gpItem->bActionValue == ACTION_ITEM_SMALL_PIT ) + if( gpItem->ItemData.Trigger.bActionValue == ACTION_ITEM_SMALL_PIT ) Add3X3Pit( gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); - else if( gpItem->bActionValue == ACTION_ITEM_LARGE_PIT ) + else if( gpItem->ItemData.Trigger.bActionValue == ACTION_ITEM_LARGE_PIT ) Add5X5Pit( gWorldItems[ gpItemPool->iItemIndex ].sGridNo ); } } diff --git a/Editor/Sector Summary.cpp b/Editor/Sector Summary.cpp index 70691571..8897394a 100644 --- a/Editor/Sector Summary.cpp +++ b/Editor/Sector Summary.cpp @@ -715,21 +715,21 @@ void RenderItemDetails() gubSummaryItemMode == ITEMMODE_REAL && !(gpWorldItemsSummaryArray[ i ].usFlags & WORLD_ITEM_SCIFI_ONLY) ) { pItem = &gpWorldItemsSummaryArray[ i ].o; - if( !pItem->bFrequency ) + if( !pItem->ItemData.Trigger.BombTrigger.bFrequency ) bFreqIndex = 7; - else if( pItem->bFrequency == PANIC_FREQUENCY ) + else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY ) bFreqIndex = 0; - else if( pItem->bFrequency == PANIC_FREQUENCY_2 ) + else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY_2 ) bFreqIndex = 1; - else if( pItem->bFrequency == PANIC_FREQUENCY_3 ) + else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY_3 ) bFreqIndex = 2; - else if( pItem->bFrequency == FIRST_MAP_PLACED_FREQUENCY + 1 ) + else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == FIRST_MAP_PLACED_FREQUENCY + 1 ) bFreqIndex = 3; - else if( pItem->bFrequency == FIRST_MAP_PLACED_FREQUENCY + 2 ) + else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == FIRST_MAP_PLACED_FREQUENCY + 2 ) bFreqIndex = 4; - else if( pItem->bFrequency == FIRST_MAP_PLACED_FREQUENCY + 3 ) + else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == FIRST_MAP_PLACED_FREQUENCY + 3 ) bFreqIndex = 5; - else if( pItem->bFrequency == FIRST_MAP_PLACED_FREQUENCY + 4 ) + else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == FIRST_MAP_PLACED_FREQUENCY + 4 ) bFreqIndex = 6; else continue; @@ -754,7 +754,7 @@ void RenderItemDetails() { pItem = &gpWorldItemsSummaryArray[ i ].o; uiExistChance += (100 - gpWorldItemsSummaryArray[ i ].ubNonExistChance) * pItem->ubNumberOfObjects; - uiStatus += pItem->bStatus[0]; + uiStatus += pItem->ItemData.Generic.bStatus[0]; uiQuantity += pItem->ubNumberOfObjects; } } @@ -862,7 +862,7 @@ void RenderItemDetails() { pItem = &gpPEnemyItemsSummaryArray[ i ]; uiExistChance += 100 * pItem->ubNumberOfObjects; - uiStatus += pItem->bStatus[0]; + uiStatus += pItem->ItemData.Generic.bStatus[0]; uiQuantity += pItem->ubNumberOfObjects; } } @@ -934,7 +934,7 @@ void RenderItemDetails() { pItem = &gpNEnemyItemsSummaryArray[ i ]; uiExistChance += 100 * pItem->ubNumberOfObjects; - uiStatus += pItem->bStatus[0]; + uiStatus += pItem->ItemData.Generic.bStatus[0]; uiQuantity += pItem->ubNumberOfObjects; } } diff --git a/Laptop/personnel.cpp b/Laptop/personnel.cpp index 6109aba4..e67e630f 100644 --- a/Laptop/personnel.cpp +++ b/Laptop/personnel.cpp @@ -2543,12 +2543,12 @@ void RenderInventoryForCharacter( INT32 iId, INT32 iSlot ) for( cnt = 0; cnt < pSoldier->inv[ ubCounter ].ubNumberOfObjects; cnt++ ) { // get total ammo - iTotalAmmo+= pSoldier->inv[ ubCounter ].ubShotsLeft[cnt]; + iTotalAmmo+= pSoldier->inv[ ubCounter ].ItemData.Ammo.ubShotsLeft[cnt]; } } else { - iTotalAmmo= pSoldier->inv[ ubCounter ].ubShotsLeft[ 0 ]; + iTotalAmmo= pSoldier->inv[ ubCounter ].ItemData.Ammo.ubShotsLeft[ 0 ]; } swprintf( sString, L"%d/%d", iTotalAmmo, ( pSoldier->inv[ ubCounter ].ubNumberOfObjects * Magazine[ Item[pSoldier->inv[ ubCounter ].usItem ].ubClassIndex ].ubMagSize ) ); @@ -2557,7 +2557,7 @@ void RenderInventoryForCharacter( INT32 iId, INT32 iSlot ) } else { - swprintf( sString, L"%2d%%%%", pSoldier->inv[ ubCounter ].bStatus[0] ); + swprintf( sString, L"%2d%%%%", pSoldier->inv[ ubCounter ].ItemData.Generic.bStatus[0] ); FindFontRightCoordinates( ( INT16 )( PosX + 65 ), ( INT16 ) ( PosY + 15 ), ( INT16 ) ( 171 - 75 ), ( INT16 )( GetFontHeight( FONT10ARIAL ) ), sString, FONT10ARIAL, &sX, &sY ); @@ -6439,7 +6439,7 @@ INT32 GetFundsOnMerc( SOLDIERTYPE *pSoldier ) { if ( Item[ pSoldier->inv[ iCurrentPocket ] .usItem ].usItemClass == IC_MONEY ) { - iCurrentAmount += pSoldier->inv[ iCurrentPocket ].uiMoneyAmount; + iCurrentAmount += pSoldier->inv[ iCurrentPocket ].ItemData.Money.uiMoneyAmount; } } @@ -6468,15 +6468,15 @@ BOOLEAN TransferFundsFromMercToBank( SOLDIERTYPE *pSoldier, INT32 iCurrentBalanc { // is there more left to go, or does this pocket finish it off? - if( pSoldier->inv[ iCurrentPocket ].uiMoneyAmount > ( UINT32 )iAmountLeftToTake ) + if( pSoldier->inv[ iCurrentPocket ].ItemData.Money.uiMoneyAmount > ( UINT32 )iAmountLeftToTake ) { - pSoldier->inv[ iCurrentPocket ].uiMoneyAmount -= iAmountLeftToTake; + pSoldier->inv[ iCurrentPocket ].ItemData.Money.uiMoneyAmount -= iAmountLeftToTake; iAmountLeftToTake = 0; } else { - iAmountLeftToTake -= pSoldier->inv[ iCurrentPocket ].uiMoneyAmount; - pSoldier->inv[ iCurrentPocket ].uiMoneyAmount = 0; + iAmountLeftToTake -= pSoldier->inv[ iCurrentPocket ].ItemData.Money.uiMoneyAmount; + pSoldier->inv[ iCurrentPocket ].ItemData.Money.uiMoneyAmount = 0; //Remove the item out off the merc RemoveObjectFromSlot( pSoldier, (INT8)iCurrentPocket, &ObjectToRemove ); @@ -6529,9 +6529,9 @@ BOOLEAN TransferFundsFromBankToMerc( SOLDIERTYPE *pSoldier, INT32 iCurrentBalanc // set up money object pMoneyObject.usItem = MONEY; pMoneyObject.ubNumberOfObjects = 1; - pMoneyObject.bMoneyStatus = 100; - pMoneyObject. bStatus[0] = 100; - pMoneyObject.uiMoneyAmount = iCurrentBalance; + pMoneyObject.ItemData.Money.bMoneyStatus = 100; + //pMoneyObject.ItemData.Generic.bStatus[0] = 100; // Isn't this the same as the previous line? + pMoneyObject.ItemData.Money.uiMoneyAmount = iCurrentBalance; // now auto place money object diff --git a/Strategic/Assignments.cpp b/Strategic/Assignments.cpp index 171ef77a..96d11453 100644 --- a/Strategic/Assignments.cpp +++ b/Strategic/Assignments.cpp @@ -764,7 +764,7 @@ BOOLEAN DoesCharacterHaveAnyItemsToRepair( SOLDIERTYPE *pSoldier, INT8 bHighestP for( ubObjectInPocketCounter = 0; ubObjectInPocketCounter < ubItemsInPocket; ubObjectInPocketCounter++ ) { // jammed gun? - if ( ( Item[ pSoldier -> inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pSoldier -> inv[ bPocket ].bGunAmmoStatus < 0 ) ) + if ( ( Item[ pSoldier -> inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pSoldier -> inv[ bPocket ].ItemData.Gun.bGunAmmoStatus < 0 ) ) { return( TRUE ); } @@ -782,7 +782,7 @@ BOOLEAN DoesCharacterHaveAnyItemsToRepair( SOLDIERTYPE *pSoldier, INT8 bHighestP for( ubObjectInPocketCounter = 0; ubObjectInPocketCounter < ubItemsInPocket; ubObjectInPocketCounter++ ) { // if it's repairable and NEEDS repairing - if ( IsItemRepairable( pObj->usItem, pObj->bStatus[ubObjectInPocketCounter] ) ) + if ( IsItemRepairable( pObj->usItem, pObj->ItemData.Generic.bStatus[ubObjectInPocketCounter] ) ) { return( TRUE ); } @@ -818,7 +818,7 @@ BOOLEAN DoesCharacterHaveAnyItemsToRepair( SOLDIERTYPE *pSoldier, INT8 bHighestP for ( bPocket = HANDPOS; bPocket <= SMALLPOCK8POS; bPocket++ ) { // the object a weapon? and jammed? - if ( ( Item[ pOtherSoldier->inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pOtherSoldier->inv[ bPocket ].bGunAmmoStatus < 0 ) ) + if ( ( Item[ pOtherSoldier->inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pOtherSoldier->inv[ bPocket ].ItemData.Gun.bGunAmmoStatus < 0 ) ) { return( TRUE ); } @@ -2981,7 +2981,7 @@ INT8 FindRepairableItemOnOtherSoldier( SOLDIERTYPE * pSoldier, UINT8 ubPassType pObj = &( pSoldier->inv[ bSlotToCheck ] ); for ( bLoop2 = 0; bLoop2 < pSoldier->inv[ bSlotToCheck ].ubNumberOfObjects; bLoop2++ ) { - if ( IsItemRepairable( pObj->usItem, pObj->bStatus[bLoop2] ) ) + if ( IsItemRepairable( pObj->usItem, pObj->ItemData.Generic.bStatus[bLoop2] ) ) { return( bSlotToCheck ); } @@ -3074,16 +3074,16 @@ BOOLEAN RepairObject( SOLDIERTYPE * pSoldier, SOLDIERTYPE * pOwner, OBJECTTYPE * for ( ubLoop = 0; ubLoop < ubItemsInPocket; ubLoop++ ) { // if it's repairable and NEEDS repairing - if ( IsItemRepairable( pObj->usItem, pObj->bStatus[ubLoop] ) ) + if ( IsItemRepairable( pObj->usItem, pObj->ItemData.Generic.bStatus[ubLoop] ) ) { // repairable, try to repair it //void DoActualRepair( SOLDIERTYPE * pSoldier, UINT16 usItem, INT8 * pbStatus, UINT8 * pubRepairPtsLeft ) - DoActualRepair( pSoldier, pObj->usItem, &(pObj->bStatus[ ubLoop ]), pubRepairPtsLeft ); + DoActualRepair( pSoldier, pObj->usItem, &(pObj->ItemData.Generic.bStatus[ ubLoop ]), pubRepairPtsLeft ); fSomethingWasRepaired = TRUE; - if ( pObj->bStatus[ ubLoop ] == 100 ) + if ( pObj->ItemData.Generic.bStatus[ ubLoop ] == 100 ) { // report it as fixed if ( pSoldier == pOwner ) @@ -11545,13 +11545,13 @@ BOOLEAN UnjamGunsOnSoldier( SOLDIERTYPE *pOwnerSoldier, SOLDIERTYPE *pRepairSold for (bPocket = HANDPOS; bPocket <= SMALLPOCK8POS; bPocket++) { // the object a weapon? and jammed? - if ( ( Item[ pOwnerSoldier->inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pOwnerSoldier->inv[ bPocket ].bGunAmmoStatus < 0 ) ) + if ( ( Item[ pOwnerSoldier->inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pOwnerSoldier->inv[ bPocket ].ItemData.Gun.bGunAmmoStatus < 0 ) ) { if ( *pubRepairPtsLeft >= gGameExternalOptions.ubRepairCostPerJam ) { *pubRepairPtsLeft -= gGameExternalOptions.ubRepairCostPerJam; - pOwnerSoldier->inv [ bPocket ].bGunAmmoStatus *= -1; + pOwnerSoldier->inv [ bPocket ].ItemData.Gun.bGunAmmoStatus *= -1; // MECHANICAL/DEXTERITY GAIN: Unjammed a gun StatChange( pRepairSoldier, MECHANAMT, 5, FALSE ); diff --git a/Strategic/Auto Resolve.cpp b/Strategic/Auto Resolve.cpp index 8262e9be..9555811b 100644 --- a/Strategic/Auto Resolve.cpp +++ b/Strategic/Auto Resolve.cpp @@ -3931,15 +3931,15 @@ BOOLEAN FireAShot( SOLDIERCELL *pAttacker ) PlayAutoResolveSample( Weapon[ pItem->usItem ].sSound, RATE_11025, 50, 1, MIDDLEPAN ); return TRUE; } - if( !pItem->ubGunShotsLeft ) + if( !pItem->ItemData.Gun.ubGunShotsLeft ) { AutoReload( pSoldier ); - if ( pItem->ubGunShotsLeft && Weapon[ pItem->usItem ].sLocknLoadSound ) + if ( pItem->ItemData.Gun.ubGunShotsLeft && Weapon[ pItem->usItem ].sLocknLoadSound ) { PlayAutoResolveSample( Weapon[ pItem->usItem ].sLocknLoadSound, RATE_11025, 50, 1, MIDDLEPAN ); } } - if( pItem->ubGunShotsLeft ) + if( pItem->ItemData.Gun.ubGunShotsLeft ) { PlayAutoResolveSample( Weapon[ pItem->usItem ].sSound, RATE_11025, 50, 1, MIDDLEPAN ); if( pAttacker->uiFlags & CELL_MERC ) @@ -3949,7 +3949,7 @@ BOOLEAN FireAShot( SOLDIERCELL *pAttacker ) StatChange( pAttacker->pSoldier, MARKAMT, 3, FALSE ); } - pItem->ubGunShotsLeft--; + pItem->ItemData.Gun.ubGunShotsLeft--; return TRUE; } } @@ -3986,7 +3986,7 @@ BOOLEAN TargetHasLoadedGun( SOLDIERTYPE *pSoldier ) { return TRUE; } - if( pItem->ubGunShotsLeft ) + if( pItem->ItemData.Gun.ubGunShotsLeft ) { return TRUE; } diff --git a/Strategic/Map Screen Interface Map Inventory.cpp b/Strategic/Map Screen Interface Map Inventory.cpp index dba45758..5c4c87cb 100644 --- a/Strategic/Map Screen Interface Map Inventory.cpp +++ b/Strategic/Map Screen Interface Map Inventory.cpp @@ -1516,7 +1516,7 @@ BOOLEAN GetObjFromInventoryStashSlot( OBJECTTYPE *pInventorySlot, OBJECTTYPE *pI pItemPtr->usItem = pInventorySlot->usItem; // find first unempty slot - pItemPtr->bStatus[0] = pInventorySlot->bStatus[0]; + pItemPtr->ItemData.Generic.bStatus[0] = pInventorySlot->ItemData.Generic.bStatus[0]; pItemPtr->ubNumberOfObjects = 1; pItemPtr->ubWeight = CalculateObjectWeight( pItemPtr ); RemoveObjFrom( pInventorySlot, 0 ); @@ -1573,7 +1573,7 @@ BOOLEAN PlaceObjectInInventoryStash( OBJECTTYPE *pInventorySlot, OBJECTTYPE *pIt // in the InSlot copy, zero out all the objects we didn't drop for (ubLoop = ubNumberToDrop; ubLoop < pItemPtr->ubNumberOfObjects; ubLoop++) { - pInventorySlot->bStatus[ubLoop] = 0; + pInventorySlot->ItemData.Generic.bStatus[ubLoop] = 0; } } pInventorySlot->ubNumberOfObjects = ubNumberToDrop; @@ -1594,8 +1594,8 @@ BOOLEAN PlaceObjectInInventoryStash( OBJECTTYPE *pInventorySlot, OBJECTTYPE *pIt { // always allow money to be combined! // average out the status values using a weighted average... - pInventorySlot->bStatus[0] = (INT8) ( ( (UINT32)pInventorySlot->bMoneyStatus * pInventorySlot->uiMoneyAmount + (UINT32)pItemPtr->bMoneyStatus * pItemPtr->uiMoneyAmount )/ (pInventorySlot->uiMoneyAmount + pItemPtr->uiMoneyAmount) ); - pInventorySlot->uiMoneyAmount += pItemPtr->uiMoneyAmount; + pInventorySlot->ItemData.Generic.bStatus[0] = (INT8) ( ( (UINT32)pInventorySlot->ItemData.Money.bMoneyStatus * pInventorySlot->ItemData.Money.uiMoneyAmount + (UINT32)pItemPtr->ItemData.Money.bMoneyStatus * pItemPtr->ItemData.Money.uiMoneyAmount )/ (pInventorySlot->ItemData.Money.uiMoneyAmount + pItemPtr->ItemData.Money.uiMoneyAmount) ); + pInventorySlot->ItemData.Money.uiMoneyAmount += pItemPtr->ItemData.Money.uiMoneyAmount; DeleteObj( pItemPtr ); } @@ -1654,7 +1654,7 @@ BOOLEAN AutoPlaceObjectInInventoryStash( OBJECTTYPE *pItemPtr ) // in the InSlot copy, zero out all the objects we didn't drop for (ubLoop = ubNumberToDrop; ubLoop < pItemPtr->ubNumberOfObjects; ubLoop++) { - pInventorySlot->bStatus[ubLoop] = 0; + pInventorySlot->ItemData.Generic.bStatus[ubLoop] = 0; } } pInventorySlot->ubNumberOfObjects = ubNumberToDrop; @@ -2238,8 +2238,8 @@ INT32 MapScreenSectorInventoryCompare( const void *pNum1, const void *pNum2) usItem1Index = pFirst->o.usItem; usItem2Index = pSecond->o.usItem; - ubItem1Quality = pFirst->o.bStatus[ 0 ]; - ubItem2Quality = pSecond->o.bStatus[ 0 ]; + ubItem1Quality = pFirst->o.ItemData.Generic.bStatus[ 0 ]; + ubItem2Quality = pSecond->o.ItemData.Generic.bStatus[ 0 ]; return( CompareItemsForSorting( usItem1Index, usItem2Index, ubItem1Quality, ubItem2Quality ) ); } @@ -2282,6 +2282,10 @@ void DeleteAllItemsInInventoryPool() ClearUpTempUnSeenList( ); SaveSeenAndUnseenItems(); + + iCurrentInventoryPoolPage = 0; + iLastInventoryPoolPage = 0; + DestroyStash(); BuildStashForSelectedSector( sSelMapX, sSelMapY, iCurrentMapSectorZ); } @@ -2315,7 +2319,7 @@ INT32 SellItem( OBJECTTYPE& object ) UINT8 magSize = Magazine[ Item[ usItemType ].ubClassIndex ].ubMagSize; for (INT8 bLoop = 0; bLoop < object.ubNumberOfObjects; bLoop++) { - iPrice += (INT32)( itemPrice * (float) object.ubShotsLeft[bLoop] / magSize ); + iPrice += (INT32)( itemPrice * (float) object.ItemData.Ammo.ubShotsLeft[bLoop] / magSize ); } } else @@ -2323,7 +2327,7 @@ INT32 SellItem( OBJECTTYPE& object ) //we are selling a gun or something - it could be stacked or single, and each one could have attachments for (INT8 bLoop = 0; bLoop < object.ubNumberOfObjects; bLoop++) { - iPrice += ( itemPrice * object.bStatus[bLoop] / 100 ); + iPrice += ( itemPrice * object.ItemData.Generic.bStatus[bLoop] / 100 ); for (INT8 numAttachments = 0; numAttachments < MAX_ATTACHMENTS; numAttachments++) { diff --git a/Strategic/Queen Command.cpp b/Strategic/Queen Command.cpp index 22456056..11404cd6 100644 --- a/Strategic/Queen Command.cpp +++ b/Strategic/Queen Command.cpp @@ -1218,7 +1218,10 @@ void AddPossiblePendingEnemiesToBattle() // Assume we added one since there are supposedly more available and room for them ubSlots--; } - return; + + // It's probable that the "pending enemies" flag isn't working right. So we'll go ahead and continue into + // the group insertion code from here. + //return; } if( pSector->ubNumElites + pSector->ubNumTroops + pSector->ubNumAdmins ) diff --git a/Strategic/Strategic Event Handler.cpp b/Strategic/Strategic Event Handler.cpp index 6d2e99cf..c7f9700f 100644 --- a/Strategic/Strategic Event Handler.cpp +++ b/Strategic/Strategic Event Handler.cpp @@ -189,7 +189,7 @@ void BobbyRayPurchaseEventCallback( UINT8 ubOrderID ) { // Empty out the bullets put in by CreateItem(). We now sell all guns empty of bullets. This is done for BobbyR // simply to be consistent with the dealers in Arulco, who must sell guns empty to prevent ammo cheats by players. - Object.ubGunShotsLeft = 0; + Object.ItemData.Gun.ubGunShotsLeft = 0; } ubItemsDelivered = 0; @@ -220,11 +220,11 @@ void BobbyRayPurchaseEventCallback( UINT8 ubOrderID ) if (usStandardMapPos == LOST_SHIPMENT_GRIDNO) { // damage the item a random amount! - Object.bStatus[0] = (INT8) ( ( (70 + Random( 11 )) * (INT32) Object.bStatus[0] ) / 100 ); + Object.ItemData.Generic.bStatus[0] = (INT8) ( ( (70 + Random( 11 )) * (INT32) Object.ItemData.Generic.bStatus[0] ) / 100 ); // make damn sure it can't hit 0 - if (Object.bStatus[0] == 0) + if (Object.ItemData.Generic.bStatus[0] == 0) { - Object.bStatus[0] = 1; + Object.ItemData.Generic.bStatus[0] = 1; } AddItemToPool( usMapPos, &Object, -1, 0, 0, 0 ); } @@ -254,11 +254,11 @@ void BobbyRayPurchaseEventCallback( UINT8 ubOrderID ) if (usStandardMapPos == LOST_SHIPMENT_GRIDNO) { // damage the item a random amount! - Object.bStatus[0] = (INT8) ( ( (70 + Random( 11 )) * (INT32) Object.bStatus[0] ) / 100 ); + Object.ItemData.Generic.bStatus[0] = (INT8) ( ( (70 + Random( 11 )) * (INT32) Object.ItemData.Generic.bStatus[0] ) / 100 ); // make damn sure it can't hit 0 - if (Object.bStatus[0] == 0) + if (Object.ItemData.Generic.bStatus[0] == 0) { - Object.bStatus[0] = 1; + Object.ItemData.Generic.bStatus[0] = 1; } memcpy( &pObject[ uiCount ], &Object, sizeof( OBJECTTYPE ) ); uiCount++; @@ -559,7 +559,7 @@ void CheckForKingpinsMoneyMissing( BOOLEAN fFirstCheck ) // loop through all items, look for ownership if ( gWorldItems[ uiLoop ].fExists && gWorldItems[ uiLoop ].o.usItem == MONEY ) { - uiTotalCash += gWorldItems[uiLoop].o.uiMoneyAmount; + uiTotalCash += gWorldItems[uiLoop].o.ItemData.Money.uiMoneyAmount; } } @@ -1043,14 +1043,14 @@ void CheckForMissingHospitalSupplies( void ) for ( uiLoop = 0; uiLoop < guiNumWorldItems; uiLoop++ ) { // loop through all items, look for ownership - if ( gWorldItems[ uiLoop ].fExists && gWorldItems[ uiLoop ].o.usItem == OWNERSHIP && gWorldItems[ uiLoop ].o.ubOwnerCivGroup == DOCTORS_CIV_GROUP ) + if ( gWorldItems[ uiLoop ].fExists && gWorldItems[ uiLoop ].o.usItem == OWNERSHIP && gWorldItems[ uiLoop ].o.ItemData.Owner.ubOwnerCivGroup == DOCTORS_CIV_GROUP ) { GetItemPool( gWorldItems[ uiLoop ].sGridNo, &pItemPool, 0 ) ; while( pItemPool ) { pObj = &( gWorldItems[ pItemPool->iItemIndex ].o ); - if ( pObj->bStatus[ 0 ] > 60 ) + if ( pObj->ItemData.Generic.bStatus[ 0 ] > 60 ) { if ( Item[pObj->usItem].firstaidkit || Item[pObj->usItem].medicalkit || pObj->usItem == REGEN_BOOSTER || pObj->usItem == ADRENALINE_BOOSTER ) { diff --git a/Strategic/Strategic Movement.cpp b/Strategic/Strategic Movement.cpp index 950d2c1d..eb5983e4 100644 --- a/Strategic/Strategic Movement.cpp +++ b/Strategic/Strategic Movement.cpp @@ -4543,17 +4543,17 @@ void AddFuelToVehicle( SOLDIERTYPE *pSoldier, SOLDIERTYPE *pVehicle ) { //Message for vehicle full? return; } - if( pItem->bStatus ) + if( pItem->ItemData.Generic.bStatus ) { //Fill 'er up. sFuelNeeded = 10000 - pVehicle->sBreathRed; - sFuelAvailable = pItem->bStatus[0] * 50; + sFuelAvailable = pItem->ItemData.Generic.bStatus[0] * 50; sFuelAdded = min( sFuelNeeded, sFuelAvailable ); //Add to vehicle pVehicle->sBreathRed += sFuelAdded; pVehicle->bBreath = (INT8)(pVehicle->sBreathRed / 100); //Subtract from item - pItem->bStatus[0] = (INT8)(pItem->bStatus[0] - sFuelAdded / 50); - if( !pItem->bStatus[0] ) + pItem->ItemData.Generic.bStatus[0] = (INT8)(pItem->ItemData.Generic.bStatus[0] - sFuelAdded / 50); + if( !pItem->ItemData.Generic.bStatus[0] ) { //Gas can is empty, so toast the item. DeleteObj( pItem ); } diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 31a7971e..5478289f 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -5230,7 +5230,7 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent ) SOLDIERTYPE *pSoldier = MercPtrs[ gCharactersList[ bSelectedInfoChar ].usSolID ]; if ( pSoldier->inv[ HANDPOS ].usItem != 0 ) { - pSoldier->inv[ HANDPOS ].bStatus[ 0 ] = 2; + pSoldier->inv[ HANDPOS ].ItemData.Generic.bStatus[ 0 ] = 2; } } } diff --git a/Strategic/strategicmap.cpp b/Strategic/strategicmap.cpp index d764e6dc..aab70bad 100644 --- a/Strategic/strategicmap.cpp +++ b/Strategic/strategicmap.cpp @@ -1741,6 +1741,11 @@ BOOLEAN SetCurrentWorldSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ ) PrepareEnemyForSectorBattle(); } + for (int i=0; ibActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE); + } + if( gubNumCreaturesAttackingTown && !gbWorldSectorZ && gubSectorIDOfCreatureAttack == SECTOR( gWorldSectorX, gWorldSectorY ) ) { @@ -1755,7 +1760,7 @@ BOOLEAN SetCurrentWorldSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ ) // Check for helicopter being on the ground in this sector... HandleHelicopterOnGroundGraphic( ); - // 0verhaul: Okay, it is apparent that the enemies are not reset incorrectly. So I will now try to add symmetry + // 0verhaul: Okay, it is apparent that the enemies are not reset correctly. So I will now try to add symmetry // between enemy placement and militia placement. The enemies do have one advantage here, though: If a sector // is in enemy hands, then their sector is not actually loaded. At least not normally. Perhaps it would be useful // to lose a battle with one group of mercs, then bring in another group without changing to another sector to see @@ -1766,6 +1771,12 @@ BOOLEAN SetCurrentWorldSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ ) // except for the case of training new militia. But that case can be handled each time militia training finishes. // ResetMilitia(); AllTeamsLookForAll( TRUE ); + + for (int i=0; ibActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE); + } + return( TRUE ); } diff --git a/Tactical/Arms Dealer Init.cpp b/Tactical/Arms Dealer Init.cpp index 1f53fb72..9e5b8540 100644 --- a/Tactical/Arms Dealer Init.cpp +++ b/Tactical/Arms Dealer Init.cpp @@ -1527,23 +1527,23 @@ void AddObjectToArmsDealerInventory( UINT8 ubArmsDealer, OBJECTTYPE *pObject ) AddItemToArmsDealerInventory( ubArmsDealer, pObject->usItem, &SpclItemInfo, 1 ); // if any GunAmmoItem is specified - if( pObject->usGunAmmoItem != NONE) + if( pObject->ItemData.Gun.usGunAmmoItem != NONE) { // if it's regular ammo - if( Item[ pObject->usGunAmmoItem ].usItemClass == IC_AMMO ) + if( Item[ pObject->ItemData.Gun.usGunAmmoItem ].usItemClass == IC_AMMO ) { // and there are some remaining - if ( pObject->ubGunShotsLeft > 0 ) + if ( pObject->ItemData.Gun.ubGunShotsLeft > 0 ) { // add the bullets of its remaining ammo - AddAmmoToArmsDealerInventory( ubArmsDealer, pObject->usGunAmmoItem, pObject->ubGunShotsLeft ); + AddAmmoToArmsDealerInventory( ubArmsDealer, pObject->ItemData.Gun.usGunAmmoItem, pObject->ItemData.Gun.ubGunShotsLeft ); } } else // assume it's attached ammo (mortar shells, grenades) { // add the launchable item (can't be imprinted, or have attachments!) SetSpecialItemInfoToDefaults( &SpclItemInfo ); - SpclItemInfo.bItemCondition = pObject->bGunAmmoStatus; + SpclItemInfo.bItemCondition = pObject->ItemData.Gun.bGunAmmoStatus; // if the gun it was in was jammed, get rid of the negative status now if ( SpclItemInfo.bItemCondition < 0 ) @@ -1551,7 +1551,7 @@ void AddObjectToArmsDealerInventory( UINT8 ubArmsDealer, OBJECTTYPE *pObject ) SpclItemInfo.bItemCondition *= -1; } - AddItemToArmsDealerInventory( ubArmsDealer, pObject->usGunAmmoItem, &SpclItemInfo, 1 ); + AddItemToArmsDealerInventory( ubArmsDealer, pObject->ItemData.Gun.usGunAmmoItem, &SpclItemInfo, 1 ); } } break; @@ -1560,7 +1560,7 @@ void AddObjectToArmsDealerInventory( UINT8 ubArmsDealer, OBJECTTYPE *pObject ) // add the contents of each magazine (multiple mags may have vastly different #bullets left) for ( ubCnt = 0; ubCnt < pObject->ubNumberOfObjects; ubCnt++ ) { - AddAmmoToArmsDealerInventory( ubArmsDealer, pObject->usItem, pObject->ubShotsLeft[ ubCnt ] ); + AddAmmoToArmsDealerInventory( ubArmsDealer, pObject->usItem, pObject->ItemData.Ammo.ubShotsLeft[ ubCnt ] ); } break; @@ -1568,7 +1568,7 @@ void AddObjectToArmsDealerInventory( UINT8 ubArmsDealer, OBJECTTYPE *pObject ) // add each object seperately (multiple objects may have vastly different statuses, keep any imprintID) for ( ubCnt = 0; ubCnt < pObject->ubNumberOfObjects; ubCnt++ ) { - SpclItemInfo.bItemCondition = pObject->bStatus[ ubCnt ]; + SpclItemInfo.bItemCondition = pObject->ItemData.Generic.bStatus[ ubCnt ]; AddItemToArmsDealerInventory( ubArmsDealer, pObject->usItem, &SpclItemInfo, 1 ); } break; @@ -2080,7 +2080,7 @@ void MakeObjectOutOfDealerItems( UINT16 usItemIndex, SPECIAL_ITEM_INFO *pSpclIte // have to keep track of #bullets in a gun throughout dealer inventory. Without this, players could "reload" guns // they don't have ammo for by selling them to Tony & buying them right back fully loaded! One could repeat this // ad nauseum (empty the gun between visits) as a (really expensive) way to get unlimited special ammo like rockets. - pObject->ubGunShotsLeft = 0; + pObject->ItemData.Gun.ubGunShotsLeft = 0; } } @@ -2102,7 +2102,7 @@ void GiveObjectToArmsDealerForRepair( UINT8 ubArmsDealer, OBJECTTYPE *pObject, U Assert( CanDealerRepairItem( ubArmsDealer, pObject->usItem ) ); // c) Actually damaged, or a rocket rifle (being reset) - Assert( ( pObject->bStatus[ 0 ] < 100 ) || ItemIsARocketRifle( pObject->usItem ) ); + Assert( ( pObject->ItemData.Generic.bStatus[ 0 ] < 100 ) || ItemIsARocketRifle( pObject->usItem ) ); /* ARM: Can now repair with removeable attachments still attached... // d) Already stripped of all *detachable* attachments @@ -2123,11 +2123,11 @@ void GiveObjectToArmsDealerForRepair( UINT8 ubArmsDealer, OBJECTTYPE *pObject, U if (Item [ pObject->usItem ].usItemClass == IC_GUN ) { // if any GunAmmoItem is specified - if( pObject->usGunAmmoItem != NONE) + if( pObject->ItemData.Gun.usGunAmmoItem != NONE) { // it better be regular ammo, and empty - Assert( Item[ pObject->usGunAmmoItem ].usItemClass == IC_AMMO ); - Assert( pObject->ubGunShotsLeft == 0 ); + Assert( Item[ pObject->ItemData.Gun.usGunAmmoItem ].usItemClass == IC_AMMO ); + Assert( pObject->ItemData.Gun.ubGunShotsLeft == 0 ); } } @@ -2250,7 +2250,7 @@ UINT32 CalculateObjectItemRepairTime( UINT8 ubArmsDealer, OBJECTTYPE *pItemObjec UINT32 uiRepairTime; UINT8 ubCnt; - uiRepairTime = CalculateSimpleItemRepairTime( ubArmsDealer, pItemObject->usItem, pItemObject->bStatus[ 0 ] ); + uiRepairTime = CalculateSimpleItemRepairTime( ubArmsDealer, pItemObject->usItem, pItemObject->ItemData.Generic.bStatus[ 0 ] ); // add time to repair any attachments on it for ( ubCnt = 0; ubCnt < MAX_ATTACHMENTS; ubCnt++ ) @@ -2334,7 +2334,7 @@ UINT32 CalculateObjectItemRepairCost( UINT8 ubArmsDealer, OBJECTTYPE *pItemObjec UINT32 uiRepairCost; UINT8 ubCnt; - uiRepairCost = CalculateSimpleItemRepairCost( ubArmsDealer, pItemObject->usItem, pItemObject->bStatus[ 0 ] ); + uiRepairCost = CalculateSimpleItemRepairCost( ubArmsDealer, pItemObject->usItem, pItemObject->ItemData.Generic.bStatus[ 0 ] ); // add cost of repairing any attachments on it for ( ubCnt = 0; ubCnt < MAX_ATTACHMENTS; ubCnt++ ) @@ -2435,7 +2435,7 @@ void SetSpecialItemInfoFromObject( SPECIAL_ITEM_INFO *pSpclItemInfo, OBJECTTYPE } else { - pSpclItemInfo->bItemCondition = pObject->bStatus[ 0 ]; + pSpclItemInfo->bItemCondition = pObject->ItemData.Generic.bStatus[ 0 ]; } // only guns currently have imprintID properly initialized... diff --git a/Tactical/ArmsDealerInvInit.cpp b/Tactical/ArmsDealerInvInit.cpp index f350aa22..f84afa9c 100644 --- a/Tactical/ArmsDealerInvInit.cpp +++ b/Tactical/ArmsDealerInvInit.cpp @@ -1240,8 +1240,8 @@ int ArmsDealerItemQsortCompare(const void *pArg1, const void *pArg2) usItem1Index = ( ( INVENTORY_IN_SLOT * ) pArg1 ) -> sItemIndex; usItem2Index = ( ( INVENTORY_IN_SLOT * ) pArg2 ) -> sItemIndex; - ubItem1Quality = ( ( INVENTORY_IN_SLOT * ) pArg1 ) -> ItemObject.bStatus[ 0 ]; - ubItem2Quality = ( ( INVENTORY_IN_SLOT * ) pArg2 ) -> ItemObject.bStatus[ 0 ]; + ubItem1Quality = ( ( INVENTORY_IN_SLOT * ) pArg1 ) -> ItemObject.ItemData.Generic.bStatus[ 0 ]; + ubItem2Quality = ( ( INVENTORY_IN_SLOT * ) pArg2 ) -> ItemObject.ItemData.Generic.bStatus[ 0 ]; return( CompareItemsForSorting( usItem1Index, usItem2Index, ubItem1Quality, ubItem2Quality ) ); } diff --git a/Tactical/Drugs And Alcohol.cpp b/Tactical/Drugs And Alcohol.cpp index 54cfcb80..254c216e 100644 --- a/Tactical/Drugs And Alcohol.cpp +++ b/Tactical/Drugs And Alcohol.cpp @@ -178,12 +178,12 @@ BOOLEAN ApplyDrugs( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject ) if ( ubDrugType == DRUG_TYPE_REGENERATION ) { // each use of a regen booster over 1, each day, reduces the effect - bRegenPointsGained = REGEN_POINTS_PER_BOOSTER * pObject->bStatus[0] / 100; + bRegenPointsGained = REGEN_POINTS_PER_BOOSTER * pObject->ItemData.Generic.bStatus[0] / 100; // are there fractional %s left over? - if ( ( pObject->bStatus[0] % (100 / REGEN_POINTS_PER_BOOSTER ) ) != 0 ) + if ( ( pObject->ItemData.Generic.bStatus[0] % (100 / REGEN_POINTS_PER_BOOSTER ) ) != 0 ) { // chance of an extra point - if ( PreRandom( 100 / REGEN_POINTS_PER_BOOSTER ) < (UINT32) ( pObject->bStatus[0] % (100 / REGEN_POINTS_PER_BOOSTER ) ) ) + if ( PreRandom( 100 / REGEN_POINTS_PER_BOOSTER ) < (UINT32) ( pObject->ItemData.Generic.bStatus[0] % (100 / REGEN_POINTS_PER_BOOSTER ) ) ) { bRegenPointsGained++; } diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index fd09c7de..84cecb83 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -213,13 +213,16 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHa if ( fFromUI ) { + INT16 sInteractiveGridNo; + // ATE: Check if we are targeting an interactive tile, and adjust gridno accordingly... - pIntNode = GetCurInteractiveTileGridNoAndStructure( &sGridNo, &pStructure ); + pIntNode = GetCurInteractiveTileGridNoAndStructure( &sInteractiveGridNo, &pStructure ); if ( pIntNode != NULL && pTargetSoldier == pSoldier ) { - // Truncate target sioldier + // Truncate target soldier and update grid pTargetSoldier = NULL; + sGridNo = sInteractiveGridNo; } } } @@ -502,7 +505,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHa pSoldier->bDoAutofire += misfirePenalty; sAPCost = CalcTotalAPsToAttack( pSoldier, sTargetGridNo, TRUE, 0 ); } - while(EnoughPoints( pSoldier, sAPCost, 0, FALSE ) && roll < ((pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft >= pSoldier->bDoAutofire)?chanceToMisfire:chanceToMisfireDry)); + while(EnoughPoints( pSoldier, sAPCost, 0, FALSE ) && roll < ((pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft >= pSoldier->bDoAutofire)?chanceToMisfire:chanceToMisfireDry)); //note that we could misfire more bullets than we have rounds //this represents the soldier running out of ammo and not noticing //the max that can be lost this way is 1AP @@ -510,17 +513,17 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHa pSoldier->bDoAutofire -= misfirePenalty; sAPCost = CalcTotalAPsToAttack( pSoldier, sTargetGridNo, TRUE, 0 ); - if((__min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft) - startAuto) > 0 && pSoldier->bTeam == OUR_TEAM) + if((__min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft) - startAuto) > 0 && pSoldier->bTeam == OUR_TEAM) { // More than 1 round - if (__min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft) - startAuto > 1) + if (__min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft) - startAuto > 1) { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, gzLateLocalizedString[ 62 ], pSoldier->name, __min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft) - startAuto ); + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, gzLateLocalizedString[ 62 ], pSoldier->name, __min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft) - startAuto ); } // 1 round else { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, gzLateLocalizedString[ 63 ], pSoldier->name, __min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft) - startAuto ); + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, gzLateLocalizedString[ 63 ], pSoldier->name, __min(pSoldier->bDoAutofire,pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft) - startAuto ); } } @@ -1421,7 +1424,7 @@ void HandleSoldierDropBomb( SOLDIERTYPE *pSoldier, INT16 sGridNo ) StatChange( pSoldier, EXPLODEAMT, 25, FALSE ); pSoldier->inv[ HANDPOS ].bTrap = __min( 10, ( EffectiveExplosive( pSoldier ) / 20) + (EffectiveExpLevel( pSoldier ) / 3) ); - pSoldier->inv[ HANDPOS ].ubBombOwner = pSoldier->ubID + 2; + pSoldier->inv[ HANDPOS ].ItemData.Trigger.ubBombOwner = pSoldier->ubID + 2; // we now know there is something nasty here gpWorldLevelData[ sGridNo ].uiFlags |= MAPELEMENT_PLAYER_MINE_PRESENT; @@ -1753,7 +1756,7 @@ void SoldierGetItemFromWorld( SOLDIERTYPE *pSoldier, INT32 iItemIndex, INT16 sGr if (Object.usItem == SWITCH) { // ask about activating the switch! - bTempFrequency = Object.bFrequency; + bTempFrequency = Object.ItemData.Trigger.BombTrigger.bFrequency; gpTempSoldier = pSoldier; DoMessageBox( MSG_BOX_BASIC_STYLE, TacticalStr[ ACTIVATE_SWITCH_PROMPT ] , GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, SwitchMessageBoxCallBack, NULL ); pItemPool = pItemPool->pNext; @@ -1846,7 +1849,7 @@ void SoldierGetItemFromWorld( SOLDIERTYPE *pSoldier, INT32 iItemIndex, INT16 sGr if (Object.usItem == SWITCH) { // handle switch - bTempFrequency = Object.bFrequency; + bTempFrequency = Object.ItemData.Trigger.BombTrigger.bFrequency; gpTempSoldier = pSoldier; DoMessageBox( MSG_BOX_BASIC_STYLE, TacticalStr[ ACTIVATE_SWITCH_PROMPT ], GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, SwitchMessageBoxCallBack, NULL ); } @@ -2274,22 +2277,22 @@ OBJECTTYPE* InternalAddItemToPool( INT16 *psGridNo, OBJECTTYPE *pObject, INT8 bV // and they are pressure-triggered unless there is a switch structure there if (FindStructure( *psGridNo, STRUCTURE_SWITCH ) != NULL) { - pObject->bDetonatorType = BOMB_SWITCH; + pObject->ItemData.Trigger.bDetonatorType = BOMB_SWITCH; } else { - pObject->bDetonatorType = BOMB_PRESSURE; + pObject->ItemData.Trigger.bDetonatorType = BOMB_PRESSURE; } } else { // else they are manually controlled - pObject->bDetonatorType = BOMB_SWITCH; + pObject->ItemData.Trigger.bDetonatorType = BOMB_SWITCH; } } else if ( pObject->usItem == ACTION_ITEM ) { - switch( pObject->bActionValue ) + switch( pObject->ItemData.Trigger.bActionValue ) { case ACTION_ITEM_SMALL_PIT: case ACTION_ITEM_LARGE_PIT: @@ -4068,7 +4071,7 @@ void SoldierGiveItemFromAnimation( SOLDIERTYPE *pSoldier ) // are we giving money to an NPC, to whom we owe money? if (pTSoldier->ubProfile != NO_PROFILE && gMercProfiles[pTSoldier->ubProfile].iBalance < 0) { - gMercProfiles[pTSoldier->ubProfile].iBalance += TempObject.uiMoneyAmount; + gMercProfiles[pTSoldier->ubProfile].iBalance += TempObject.ItemData.Money.uiMoneyAmount; if (gMercProfiles[pTSoldier->ubProfile].iBalance >= 0) { // don't let the player accumulate credit (?) @@ -4276,7 +4279,7 @@ void BombMessageBoxCallBack( UINT8 ubExitValue ) // HACK IMMINENT! // value of 1 is stored in maps for SIDE of bomb owner... when we want to use IDs! // so we add 2 to all owner IDs passed through here and subtract 2 later - gpTempSoldier->inv[HANDPOS].ubBombOwner = gpTempSoldier->ubID + 2; + gpTempSoldier->inv[HANDPOS].ItemData.Trigger.ubBombOwner = gpTempSoldier->ubID + 2; AddItemToPool( gsTempGridno, &(gpTempSoldier->inv[HANDPOS]), 1, gpTempSoldier->bLevel, WORLD_ITEM_ARMED_BOMB, 0 ); DeleteObj( &(gpTempSoldier->inv[HANDPOS]) ); } @@ -4300,17 +4303,17 @@ BOOLEAN HandItemWorks( SOLDIERTYPE *pSoldier, INT8 bSlot ) if ( (Item[ pObj->usItem ].damageable ) && (!Item[pObj->usItem].mine ) && (Item[ pObj->usItem ].usItemClass != IC_MEDKIT) && !Item[pObj->usItem].gascan ) { // if it's still usable, check whether it breaks - if ( pObj->bStatus[0] >= USABLE) + if ( pObj->ItemData.Generic.bStatus[0] >= USABLE) { // if a dice roll is greater than the item's status - if ( (Random(80) + 20) >= (UINT32) (pObj->bStatus[0] + 50) ) + if ( (Random(80) + 20) >= (UINT32) (pObj->ItemData.Generic.bStatus[0] + 50) ) { fItemJustBroke = TRUE; fItemWorks = FALSE; // item breaks, and becomes unusable... so its status is reduced // to somewhere between 1 and the 1 less than USABLE - pObj->bStatus[0] = (INT8) ( 1 + Random( USABLE - 1 ) ); + pObj->ItemData.Generic.bStatus[0] = (INT8) ( 1 + Random( USABLE - 1 ) ); } } else // it's already unusable @@ -4333,8 +4336,8 @@ BOOLEAN HandItemWorks( SOLDIERTYPE *pSoldier, INT8 bSlot ) { // are we using two guns at once? if ( Item[ pSoldier->inv[SECONDHANDPOS].usItem ].usItemClass == IC_GUN && - pSoldier->inv[SECONDHANDPOS].bGunStatus >= USABLE && - pSoldier->inv[SECONDHANDPOS].ubGunShotsLeft > 0) + pSoldier->inv[SECONDHANDPOS].ItemData.Gun.bGunStatus >= USABLE && + pSoldier->inv[SECONDHANDPOS].ItemData.Gun.ubGunShotsLeft > 0) { // check the second gun for breakage, and if IT breaks, return false return( HandItemWorks( pSoldier, SECONDHANDPOS ) ); @@ -4508,9 +4511,9 @@ void BoobyTrapMessageBoxCallBack( UINT8 ubExitValue ) // NB owner grossness... bombs 'owned' by the enemy are stored with side value 1 in // the map. So if we want to detect a bomb placed by the player, owner is > 1, and // owner - 2 gives the ID of the character who planted it - if ( Object.ubBombOwner > 1 && ( (INT32)Object.ubBombOwner - 2 >= gTacticalStatus.Team[ OUR_TEAM ].bFirstID && Object.ubBombOwner - 2 <= gTacticalStatus.Team[ OUR_TEAM ].bLastID ) ) + if ( Object.ItemData.Trigger.ubBombOwner > 1 && ( (INT32)Object.ItemData.Trigger.ubBombOwner - 2 >= gTacticalStatus.Team[ OUR_TEAM ].bFirstID && Object.ItemData.Trigger.ubBombOwner - 2 <= gTacticalStatus.Team[ OUR_TEAM ].bLastID ) ) { - if ( Object.ubBombOwner - 2 == gpBoobyTrapSoldier->ubID ) + if ( Object.ItemData.Trigger.ubBombOwner - 2 == gpBoobyTrapSoldier->ubID ) { // my own boobytrap! iCheckResult = SkillCheck( gpBoobyTrapSoldier, DISARM_TRAP_CHECK, 40 ); @@ -4529,9 +4532,9 @@ void BoobyTrapMessageBoxCallBack( UINT8 ubExitValue ) if (iCheckResult >= 0) { - if ( Object.ubBombOwner > 1 && ( (INT32)Object.ubBombOwner - 2 >= gTacticalStatus.Team[ OUR_TEAM ].bFirstID && Object.ubBombOwner - 2 <= gTacticalStatus.Team[ OUR_TEAM ].bLastID ) ) + if ( Object.ItemData.Trigger.ubBombOwner > 1 && ( (INT32)Object.ItemData.Trigger.ubBombOwner - 2 >= gTacticalStatus.Team[ OUR_TEAM ].bFirstID && Object.ItemData.Trigger.ubBombOwner - 2 <= gTacticalStatus.Team[ OUR_TEAM ].bLastID ) ) { - if ( Object.ubBombOwner - 2 == gpBoobyTrapSoldier->ubID ) + if ( Object.ItemData.Trigger.ubBombOwner - 2 == gpBoobyTrapSoldier->ubID ) { // disarmed my own boobytrap! StatChange( gpBoobyTrapSoldier, EXPLODEAMT, (UINT16) (2 * gbTrapDifficulty), FALSE ); @@ -4558,7 +4561,7 @@ void BoobyTrapMessageBoxCallBack( UINT8 ubExitValue ) // give the player a remote trigger instead CreateItem( REMOTEBOMBTRIGGER, (INT8) (1 + Random( 9 )), &Object ); } - else if (Object.usItem == ACTION_ITEM && Object.bActionValue != ACTION_ITEM_BLOW_UP ) + else if (Object.usItem == ACTION_ITEM && Object.ItemData.Trigger.bActionValue != ACTION_ITEM_BLOW_UP ) { // give the player a detonator instead CreateItem( DETONATOR, (INT8) (1 + Random( 9 )), &Object ); @@ -4566,7 +4569,7 @@ void BoobyTrapMessageBoxCallBack( UINT8 ubExitValue ) else { // switch action item to the real item type - CreateItem( Object.usBombItem, Object.bBombStatus, &Object ); + CreateItem( Object.ItemData.Trigger.usBombItem, Object.ItemData.Trigger.bBombStatus, &Object ); } // remove any blue flag graphic @@ -4662,7 +4665,7 @@ void BoobyTrapInMapScreenMessageBoxCallBack( UINT8 ubExitValue ) // give the player a remote trigger instead CreateItem( REMOTEBOMBTRIGGER, (INT8) (1 + Random( 9 )), &Object ); } - else if (Object.usItem == ACTION_ITEM && Object.bActionValue != ACTION_ITEM_BLOW_UP ) + else if (Object.usItem == ACTION_ITEM && Object.ItemData.Trigger.bActionValue != ACTION_ITEM_BLOW_UP ) { // give the player a detonator instead CreateItem( DETONATOR, (INT8) (1 + Random( 9 )), &Object ); @@ -4670,7 +4673,7 @@ void BoobyTrapInMapScreenMessageBoxCallBack( UINT8 ubExitValue ) else { // switch action item to the real item type - CreateItem( Object.usBombItem, Object.bBombStatus, &Object ); + CreateItem( Object.ItemData.Trigger.usBombItem, Object.ItemData.Trigger.bBombStatus, &Object ); } } else @@ -4824,7 +4827,7 @@ BOOLEAN NearbyGroundSeemsWrong( SOLDIERTYPE * pSoldier, INT16 sGridNo, BOOLEAN f if (gWorldBombs[uiWorldBombIndex].fExists && gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].sGridNo == sNextGridNo) { pObj = &( gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].o ); - if ( pObj->bDetonatorType == BOMB_PRESSURE && !(pObj->fFlags & OBJECT_KNOWN_TO_BE_TRAPPED) && (!(pObj->fFlags & OBJECT_DISABLED_BOMB)) ) + if ( pObj->ItemData.Trigger.bDetonatorType == BOMB_PRESSURE && !(pObj->fFlags & OBJECT_KNOWN_TO_BE_TRAPPED) && (!(pObj->fFlags & OBJECT_DISABLED_BOMB)) ) { if ( fMining && pObj->bTrap <= 10 ) { @@ -5047,18 +5050,18 @@ void CheckForPickedOwnership( void ) { if ( gWorldItems[ pItemPool->iItemIndex ].o.usItem == OWNERSHIP ) { - if ( gWorldItems[ pItemPool->iItemIndex ].o.ubOwnerProfile != NO_PROFILE ) + if ( gWorldItems[ pItemPool->iItemIndex ].o.ItemData.Owner.ubOwnerProfile != NO_PROFILE ) { - ubProfile = gWorldItems[ pItemPool->iItemIndex ].o.ubOwnerProfile; + ubProfile = gWorldItems[ pItemPool->iItemIndex ].o.ItemData.Owner.ubOwnerProfile; pSoldier = FindSoldierByProfileID( ubProfile, FALSE ); if ( pSoldier ) { TestPotentialOwner( pSoldier ); } } - if ( gWorldItems[ pItemPool->iItemIndex ].o.ubOwnerCivGroup != NON_CIV_GROUP ) + if ( gWorldItems[ pItemPool->iItemIndex ].o.ItemData.Owner.ubOwnerCivGroup != NON_CIV_GROUP ) { - ubCivGroup = gWorldItems[ pItemPool->iItemIndex ].o.ubOwnerCivGroup; + ubCivGroup = gWorldItems[ pItemPool->iItemIndex ].o.ItemData.Owner.ubOwnerCivGroup; if ( ubCivGroup == HICKS_CIV_GROUP && CheckFact( FACT_HICKS_MARRIED_PLAYER_MERC, 0 ) ) { // skip because hicks appeased diff --git a/Tactical/Interface Dialogue.cpp b/Tactical/Interface Dialogue.cpp index f7e3be55..64f92cf5 100644 --- a/Tactical/Interface Dialogue.cpp +++ b/Tactical/Interface Dialogue.cpp @@ -2371,7 +2371,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum if (pSoldier) { CreateItem( MONEY, 1, &Object ); - Object.uiMoneyAmount = 10000; + Object.ItemData.Money.uiMoneyAmount = 10000; AddItemToPoolAndGetIndex( sGridNo, &Object, -1, pSoldier->bLevel, 0, 0, &iWorldItem ); // shouldn't have any current action but make sure everything @@ -3110,7 +3110,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum if (bMoneySlot != NO_SLOT && bEmptySlot != NO_SLOT) { CreateMoney( gMercProfiles[ ubTargetNPC ].iBalance * 2, &(pSoldier->inv[ bEmptySlot ] ) ); - pSoldier->inv[ bMoneySlot ].uiMoneyAmount -= gMercProfiles[ ubTargetNPC ].iBalance * 2; + pSoldier->inv[ bMoneySlot ].ItemData.Money.uiMoneyAmount -= gMercProfiles[ ubTargetNPC ].iBalance * 2; if (bMoneySlot < bEmptySlot) { // move main stash to later in inventory! diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 19c9dcf7..73c85d41 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -610,7 +610,7 @@ void GenerateProsString( STR16 zItemPros, OBJECTTYPE * pObject, UINT32 uiPixLimi ubWeight = Item[ usItem ].ubWeight; if (Item[ usItem ].usItemClass == IC_GUN) { - ubWeight += Item[ pObject->usGunAmmoItem ].ubWeight; + ubWeight += Item[ pObject->ItemData.Gun.usGunAmmoItem ].ubWeight; } if (Weapon[usItem].bAccuracy >= EXCEPTIONAL_ACCURACY ) @@ -753,7 +753,7 @@ void GenerateConsString( STR16 zItemCons, OBJECTTYPE * pObject, UINT32 uiPixLimi ubWeight = Item[ usItem ].ubWeight; if (Item[ usItem ].usItemClass == IC_GUN) { - ubWeight += Item[ pObject->usGunAmmoItem ].ubWeight; + ubWeight += Item[ pObject->ItemData.Gun.usGunAmmoItem ].ubWeight; } if (ubWeight >= BAD_WEIGHT) @@ -1079,7 +1079,7 @@ void HandleRenderInvSlots( SOLDIERTYPE *pSoldier, UINT8 fDirtyLevel ) if ( fDirtyLevel == DIRTYLEVEL2 ) { # if defined( _DEBUG ) /* Sergeant_Kolja, to be removed later again */ - if( pSoldier->inv[ cnt ].ubGunAmmoType >= MAXITEMS ) + if( pSoldier->inv[ cnt ].ItemData.Gun.ubGunAmmoType >= MAXITEMS ) { DebugMsg(TOPIC_JA2, DBG_LEVEL_1, String("pObject (%s) corrupted! GetHelpTextForItem() can crash.", (pSoldier->inv[ cnt ].usIteminv[ cnt ].usItem].szItemName : "???" )); ScreenMsg( MSG_FONT_RED, MSG_DEBUG, L"pObject (%S) corrupted! GetHelpTextForItem() can crash.", (pSoldier->inv[ cnt ].usIteminv[ cnt ].usItem].szItemName : "???" ); @@ -2082,7 +2082,7 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec sNewY = sY + sHeight - 10; sNewX = sX + 1; - SetFontForeground ( AmmoTypes[pObject->ubGunAmmoType].fontColour ); + SetFontForeground ( AmmoTypes[pObject->ItemData.Gun.ubGunAmmoType].fontColour ); //switch (pObject->ubGunAmmoType) //{ // case AMMO_AP: @@ -2108,7 +2108,7 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec //} - swprintf( pStr, L"%d", pObject->ubGunShotsLeft ); + swprintf( pStr, L"%d", pObject->ItemData.Gun.ubGunShotsLeft ); if ( uiBuffer == guiSAVEBUFFER ) { RestoreExternBackgroundRect( sNewX, sNewY, 20, 15 ); @@ -2119,7 +2119,7 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec SetFontForeground( FONT_MCOLOR_DKGRAY ); // Display 'JAMMED' if we are jammed - if ( pObject->bGunAmmoStatus < 0 ) + if ( pObject->ItemData.Gun.bGunAmmoStatus < 0 ) { SetFontForeground( FONT_MCOLOR_RED ); @@ -2436,14 +2436,14 @@ BOOLEAN InternalInitItemDescriptionBox( OBJECTTYPE *pObject, INT16 sX, INT16 sY, // if( guiCurrentScreen != MAP_SCREEN ) //if( guiCurrentItemDescriptionScreen != MAP_SCREEN ) if ( GetMagSize(gpItemDescObject) <= 99 ) - swprintf( pStr, L"%d/%d", gpItemDescObject->ubGunShotsLeft, GetMagSize(gpItemDescObject)); + swprintf( pStr, L"%d/%d", gpItemDescObject->ItemData.Gun.ubGunShotsLeft, GetMagSize(gpItemDescObject)); else - swprintf( pStr, L"%d", gpItemDescObject->ubGunShotsLeft ); + swprintf( pStr, L"%d", gpItemDescObject->ItemData.Gun.ubGunShotsLeft ); FilenameForBPP("INTERFACE\\infobox.sti", ubString); sForeColour = ITEMDESC_AMMO_FORE; - giItemDescAmmoButtonImages = LoadButtonImage(ubString,AmmoTypes[pObject->ubGunAmmoType].grayed,AmmoTypes[pObject->ubGunAmmoType].offNormal,-1,AmmoTypes[pObject->ubGunAmmoType].onNormal,-1 ); + giItemDescAmmoButtonImages = LoadButtonImage(ubString,AmmoTypes[pObject->ItemData.Gun.ubGunAmmoType].grayed,AmmoTypes[pObject->ItemData.Gun.ubGunAmmoType].offNormal,-1,AmmoTypes[pObject->ItemData.Gun.ubGunAmmoType].onNormal,-1 ); //switch( pObject->ubGunAmmoType ) //{ @@ -2630,8 +2630,8 @@ BOOLEAN InternalInitItemDescriptionBox( OBJECTTYPE *pObject, INT16 sX, INT16 sY, else { memset( &gRemoveMoney, 0, sizeof( REMOVE_MONEY ) ); - gRemoveMoney.uiTotalAmount = gpItemDescObject->uiMoneyAmount; - gRemoveMoney.uiMoneyRemaining = gpItemDescObject->uiMoneyAmount; + gRemoveMoney.uiTotalAmount = gpItemDescObject->ItemData.Money.uiMoneyAmount; + gRemoveMoney.uiMoneyRemaining = gpItemDescObject->ItemData.Money.uiMoneyAmount; gRemoveMoney.uiMoneyRemoving = 0; // Load graphic @@ -3281,12 +3281,12 @@ void RenderItemDescriptionBox( ) if( Item[gpItemDescObject->usItem].usItemClass == IC_AMMO && gpItemDescObject->ubNumberOfObjects > 1 && gubItemDescStatusIndex < gpItemDescObject->ubNumberOfObjects) { //Get weight of one item in stack. - UINT8 ubShotsLeftFirst = gpItemDescObject->ubShotsLeft[0]; + UINT8 ubShotsLeftFirst = gpItemDescObject->ItemData.Ammo.ubShotsLeft[0]; UINT8 ubNumberOfObjects = gpItemDescObject->ubNumberOfObjects; gpItemDescObject->ubNumberOfObjects = 1; - gpItemDescObject->ubShotsLeft[0] = gpItemDescObject->ubShotsLeft[gubItemDescStatusIndex]; + gpItemDescObject->ItemData.Ammo.ubShotsLeft[0] = gpItemDescObject->ItemData.Ammo.ubShotsLeft[gubItemDescStatusIndex]; fWeight = (float)(CalculateObjectWeight( gpItemDescObject )) / 10; - gpItemDescObject->ubShotsLeft[0] = ubShotsLeftFirst; + gpItemDescObject->ItemData.Ammo.ubShotsLeft[0] = ubShotsLeftFirst; gpItemDescObject->ubNumberOfObjects = ubNumberOfObjects; } //Item does not exist @@ -3349,7 +3349,7 @@ void RenderItemDescriptionBox( ) SetFontForeground( 5 ); //Status // This is gross, but to get the % to work out right... - swprintf( pStr, L"%2d%%", gpItemDescObject->bStatus[ gubItemDescStatusIndex ] ); + swprintf( pStr, L"%2d%%", gpItemDescObject->ItemData.Generic.bStatus[ gubItemDescStatusIndex ] ); FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 1 ].sX + gsInvDescX + gMapWeaponStats[ 1 ].sValDx + 6), (INT16)(gMapWeaponStats[ 1 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); wcscat( pStr, L"%%" ); mprintf( usX, usY, pStr ); @@ -3521,7 +3521,7 @@ void RenderItemDescriptionBox( ) { SetFontForeground( FONT_FCOLOR_WHITE ); SetFontShadow( DEFAULT_SHADOW ); - swprintf( pStr, L"%ld", gpItemDescObject->uiMoneyAmount ); + swprintf( pStr, L"%ld", gpItemDescObject->ItemData.Money.uiMoneyAmount ); InsertCommasForDollarFigure( pStr ); InsertDollarSignInToString( pStr ); uiStringLength=StringPixLength(pStr, ITEMDESC_FONT ); @@ -3554,7 +3554,7 @@ void RenderItemDescriptionBox( ) if ( Item[ gpItemDescObject->usItem ].usItemClass & IC_AMMO ) { // Ammo - swprintf( pStr, L"%d/%d", gpItemDescObject->ubShotsLeft[gubItemDescStatusIndex], Magazine[ Item[ gpItemDescObject->usItem ].ubClassIndex ].ubMagSize ); //Pulmu: Correct # of rounds for stacked ammo. + swprintf( pStr, L"%d/%d", gpItemDescObject->ItemData.Ammo.ubShotsLeft[gubItemDescStatusIndex], Magazine[ Item[ gpItemDescObject->usItem ].ubClassIndex ].ubMagSize ); //Pulmu: Correct # of rounds for stacked ammo. uiStringLength=StringPixLength(pStr, ITEMDESC_FONT ); // sStrX = gMapWeaponStats[ 0 ].sX + gsInvDescX + gMapWeaponStats[ 0 ].sValDx + ( uiRightLength - uiStringLength ); FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 2 ].sX + gsInvDescX + gMapWeaponStats[ 2 ].sValDx+6), (INT16)(gMapWeaponStats[ 2 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &sStrX, &usY); @@ -3563,7 +3563,7 @@ void RenderItemDescriptionBox( ) else { //Status - swprintf( pStr, L"%2d%%", gpItemDescObject->bStatus[ gubItemDescStatusIndex ] ); + swprintf( pStr, L"%2d%%", gpItemDescObject->ItemData.Generic.bStatus[ gubItemDescStatusIndex ] ); uiStringLength=StringPixLength(pStr, ITEMDESC_FONT ); // sStrX = gMapWeaponStats[ 1 ].sX + gsInvDescX + gMapWeaponStats[ 1 ].sValDx + ( uiRightLength - uiStringLength ); FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 1 ].sX + gsInvDescX + gMapWeaponStats[ 1 ].sValDx + 6), (INT16)(gMapWeaponStats[ 1 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &sStrX, &usY); @@ -3590,12 +3590,12 @@ void RenderItemDescriptionBox( ) SetFontForeground( 5 ); - GetShortSectorString( ( INT16 ) SECTORX( KeyTable[ gpItemDescObject->ubKeyID ].usSectorFound ), ( INT16 ) SECTORY( KeyTable[ gpItemDescObject->ubKeyID ].usSectorFound ), sTempString ); + GetShortSectorString( ( INT16 ) SECTORX( KeyTable[ gpItemDescObject->ItemData.Key.ubKeyID ].usSectorFound ), ( INT16 ) SECTORY( KeyTable[ gpItemDescObject->ItemData.Key.ubKeyID ].usSectorFound ), sTempString ); swprintf( pStr, L"%s", sTempString ); FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 4 ].sX + gsInvDescX ), (INT16)(gMapWeaponStats[ 4 ].sY + gsInvDescY ), 110 ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); mprintf( usX, usY, pStr ); - swprintf( pStr, L"%d", KeyTable[ gpItemDescObject->ubKeyID ].usDateFound ); + swprintf( pStr, L"%d", KeyTable[ gpItemDescObject->ItemData.Key.ubKeyID ].usDateFound ); FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 4 ].sX + gsInvDescX ), (INT16)(gMapWeaponStats[ 4 ].sY + gsInvDescY + GetFontHeight( BLOCKFONT ) + 2 ), 110 ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); mprintf( usX, usY, pStr ); } @@ -3775,12 +3775,12 @@ void RenderItemDescriptionBox( ) if( Item[gpItemDescObject->usItem].usItemClass == IC_AMMO && gpItemDescObject->ubNumberOfObjects > 1 && gubItemDescStatusIndex < gpItemDescObject->ubNumberOfObjects) { //Get weight of one ammo clip in stack. - UINT8 ubShotsLeftFirst = gpItemDescObject->ubShotsLeft[0]; + UINT8 ubShotsLeftFirst = gpItemDescObject->ItemData.Ammo.ubShotsLeft[0]; UINT8 ubNumberOfObjects = gpItemDescObject->ubNumberOfObjects; gpItemDescObject->ubNumberOfObjects = 1; - gpItemDescObject->ubShotsLeft[0] = gpItemDescObject->ubShotsLeft[gubItemDescStatusIndex]; + gpItemDescObject->ItemData.Ammo.ubShotsLeft[0] = gpItemDescObject->ItemData.Ammo.ubShotsLeft[gubItemDescStatusIndex]; fWeight = (float)(CalculateObjectWeight( gpItemDescObject )) / 10; - gpItemDescObject->ubShotsLeft[0] = ubShotsLeftFirst; + gpItemDescObject->ItemData.Ammo.ubShotsLeft[0] = ubShotsLeftFirst; gpItemDescObject->ubNumberOfObjects = ubNumberOfObjects; } //Item does not exist @@ -3850,7 +3850,7 @@ void RenderItemDescriptionBox( ) } //Status - swprintf( pStr, L"%2d%%", gpItemDescObject->bGunStatus ); + swprintf( pStr, L"%2d%%", gpItemDescObject->ItemData.Gun.bGunStatus ); FindFontRightCoordinates( (INT16)(gWeaponStats[ 1 ].sX + gsInvDescX + gWeaponStats[ 1 ].sValDx), (INT16)(gWeaponStats[ 1 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); wcscat( pStr, L"%%" ); mprintf( usX, usY, pStr ); @@ -4018,7 +4018,7 @@ void RenderItemDescriptionBox( ) { SetFontForeground( FONT_FCOLOR_WHITE ); SetFontShadow( DEFAULT_SHADOW ); - swprintf( pStr, L"%ld", gpItemDescObject->uiMoneyAmount ); + swprintf( pStr, L"%ld", gpItemDescObject->ItemData.Money.uiMoneyAmount ); InsertCommasForDollarFigure( pStr ); InsertDollarSignInToString( pStr ); @@ -4054,14 +4054,14 @@ void RenderItemDescriptionBox( ) { // Ammo - print amount //Status - swprintf( pStr, L"%d/%d", gpItemDescObject->ubShotsLeft[gubItemDescStatusIndex], Magazine[ Item[ gpItemDescObject->usItem ].ubClassIndex ].ubMagSize ); //Pulmu: Correct # of rounds for stacked ammo + swprintf( pStr, L"%d/%d", gpItemDescObject->ItemData.Ammo.ubShotsLeft[gubItemDescStatusIndex], Magazine[ Item[ gpItemDescObject->usItem ].ubClassIndex ].ubMagSize ); //Pulmu: Correct # of rounds for stacked ammo FindFontRightCoordinates( (INT16)(gWeaponStats[ 2 ].sX + gsInvDescX + gWeaponStats[ 2 ].sValDx), (INT16)(gWeaponStats[ 2 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); mprintf( usX, usY, pStr ); } else { //Status - swprintf( pStr, L"%2d%%", gpItemDescObject->bStatus[ gubItemDescStatusIndex ] ); + swprintf( pStr, L"%2d%%", gpItemDescObject->ItemData.Generic.bStatus[ gubItemDescStatusIndex ] ); FindFontRightCoordinates( (INT16)(gWeaponStats[ 1 ].sX + gsInvDescX + gWeaponStats[ 1 ].sValDx), (INT16)(gWeaponStats[ 1 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); wcscat( pStr, L"%%" ); mprintf( usX, usY, pStr ); @@ -4079,12 +4079,12 @@ void RenderItemDescriptionBox( ) SetFontForeground( 5 ); - GetShortSectorString( ( INT16 ) SECTORX( KeyTable[ gpItemDescObject->ubKeyID ].usSectorFound ), ( INT16 ) SECTORY( KeyTable[ gpItemDescObject->ubKeyID ].usSectorFound ), sTempString ); + GetShortSectorString( ( INT16 ) SECTORX( KeyTable[ gpItemDescObject->ItemData.Key.ubKeyID ].usSectorFound ), ( INT16 ) SECTORY( KeyTable[ gpItemDescObject->ItemData.Key.ubKeyID ].usSectorFound ), sTempString ); swprintf( pStr, L"%s", sTempString ); FindFontRightCoordinates( (INT16)(gWeaponStats[ 4 ].sX + gsInvDescX ), (INT16)(gWeaponStats[ 4 ].sY + gsInvDescY ), 110 ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); mprintf( usX, usY, pStr ); - swprintf( pStr, L"%d", KeyTable[ gpItemDescObject->ubKeyID ].usDateFound ); + swprintf( pStr, L"%d", KeyTable[ gpItemDescObject->ItemData.Key.ubKeyID ].usDateFound ); FindFontRightCoordinates( (INT16)(gWeaponStats[ 4 ].sX + gsInvDescX ), (INT16)(gWeaponStats[ 4 ].sY + gsInvDescY + GetFontHeight( BLOCKFONT ) + 2 ), 110 ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); mprintf( usX, usY, pStr ); } @@ -5673,7 +5673,7 @@ void RenderKeyRingPopup( BOOLEAN fFullRender ) memset( &pObject, 0, sizeof( OBJECTTYPE ) ); pObject.usItem = KEY_1; - pObject.bStatus[ 0 ] = 100; + pObject.ItemData.Generic.bStatus[ 0 ] = 100; // TAKE A LOOK AT THE VIDEO OBJECT SIZE ( ONE OF TWO SIZES ) AND CENTER! GetVideoObject( &hVObject, guiItemPopupBoxes ); @@ -6517,7 +6517,7 @@ void SetupPickupPage( INT8 bPage ) pObject = (gfStealing)? &gpOpponent->inv[pTempItemPool->iItemIndex] :&(gWorldItems[ pTempItemPool->iItemIndex ].o ); - sValue = pObject->bStatus[ 0 ]; + sValue = pObject->ItemData.Generic.bStatus[ 0 ]; // Adjust for ammo, other thingys.. if( Item[ pObject->usItem ].usItemClass & IC_AMMO || Item[ pObject->usItem ].usItemClass & IC_KEY ) @@ -6789,7 +6789,7 @@ void RenderItemPickupMenu( ) if ( Item[ pObject->usItem ].usItemClass == IC_MONEY ) { CHAR16 pStr2[20]; - swprintf( pStr2, L"%ld", pObject->uiMoneyAmount ); + swprintf( pStr2, L"%ld", pObject->ItemData.Money.uiMoneyAmount ); InsertCommasForDollarFigure( pStr2 ); InsertDollarSignInToString( pStr2 ); @@ -7337,22 +7337,22 @@ void RemoveMoney() InvSlot.bSlotIdInOtherLocation = -1; //Remove the money from the money in the pocket - gpItemDescObject->uiMoneyAmount = gRemoveMoney.uiMoneyRemaining; + gpItemDescObject->ItemData.Money.uiMoneyAmount = gRemoveMoney.uiMoneyRemaining; //Create an item to get the money that is being removed CreateItem( MONEY, 0, &InvSlot.ItemObject ); //Set the amount thast is being removed - InvSlot.ItemObject.uiMoneyAmount = gRemoveMoney.uiMoneyRemoving; + InvSlot.ItemObject.ItemData.Money.uiMoneyAmount = gRemoveMoney.uiMoneyRemoving; InvSlot.ubIdOfMercWhoOwnsTheItem = gpItemDescSoldier->ubProfile; //if we are removing money from the players account if( gfAddingMoneyToMercFromPlayersAccount ) { - gpItemDescObject->uiMoneyAmount = gRemoveMoney.uiMoneyRemoving; + gpItemDescObject->ItemData.Money.uiMoneyAmount = gRemoveMoney.uiMoneyRemoving; //take the money from the player - AddTransactionToPlayersBook ( TRANSFER_FUNDS_TO_MERC, gpSMCurrentMerc->ubProfile, GetWorldTotalMin() , -(INT32)( gpItemDescObject->uiMoneyAmount ) ); + AddTransactionToPlayersBook ( TRANSFER_FUNDS_TO_MERC, gpSMCurrentMerc->ubProfile, GetWorldTotalMin() , -(INT32)( gpItemDescObject->ItemData.Money.uiMoneyAmount ) ); } memcpy( &gMoveingItem, &InvSlot, sizeof( INVENTORY_IN_SLOT ) ); @@ -7378,13 +7378,13 @@ void RemoveMoney() //if we are removing money from the players account if( gfAddingMoneyToMercFromPlayersAccount ) { - gpItemDescObject->uiMoneyAmount = gRemoveMoney.uiMoneyRemoving; + gpItemDescObject->ItemData.Money.uiMoneyAmount = gRemoveMoney.uiMoneyRemoving; //take the money from the player - AddTransactionToPlayersBook ( TRANSFER_FUNDS_TO_MERC, gpSMCurrentMerc->ubProfile, GetWorldTotalMin() , -(INT32)( gpItemDescObject->uiMoneyAmount ) ); + AddTransactionToPlayersBook ( TRANSFER_FUNDS_TO_MERC, gpSMCurrentMerc->ubProfile, GetWorldTotalMin() , -(INT32)( gpItemDescObject->ItemData.Money.uiMoneyAmount ) ); } else - gpItemDescObject->uiMoneyAmount = gRemoveMoney.uiMoneyRemaining; + gpItemDescObject->ItemData.Money.uiMoneyAmount = gRemoveMoney.uiMoneyRemaining; @@ -7438,7 +7438,7 @@ void GetHelpTextForItem( STR16 pzStr, OBJECTTYPE *pObject, SOLDIERTYPE *pSoldier Remove when fixed! */ # if defined( _DEBUG ) - if ( (pObject->ubGunAmmoType >= MAXITEMS) + if ( (pObject->ItemData.Gun.ubGunAmmoType >= MAXITEMS) ) { DebugMsg(TOPIC_JA2, DBG_LEVEL_1, String( "corrupted pObject (%s) found in GetHelpTextForItem()", (usItembStatus[ 0 ]; + INT16 sValue = pObject->ItemData.Generic.bStatus[ 0 ]; for(INT16 i = 1; i < pObject->ubNumberOfObjects; i++) { - if(pObject->bStatus[ i ] < sValue) + if(pObject->ItemData.Generic.bStatus[ i ] < sValue) { - sValue = pObject->bStatus[ i ]; + sValue = pObject->ItemData.Generic.bStatus[ i ]; } } @@ -7485,7 +7485,7 @@ void GetHelpTextForItem( STR16 pzStr, OBJECTTYPE *pObject, SOLDIERTYPE *pSoldier case MONEY: //Money { - swprintf( pStr, L"%ld", pObject->uiMoneyAmount ); + swprintf( pStr, L"%ld", pObject->ItemData.Money.uiMoneyAmount ); InsertCommasForDollarFigure( pStr ); InsertDollarSignInToString( pStr ); } @@ -7496,7 +7496,7 @@ void GetHelpTextForItem( STR16 pzStr, OBJECTTYPE *pObject, SOLDIERTYPE *pSoldier //if ( Item[ usItem ].usItemClass == IC_MONEY ) { CHAR16 pStr2[20]; - swprintf( pStr2, L"%ld", pObject->uiMoneyAmount ); + swprintf( pStr2, L"%ld", pObject->ItemData.Money.uiMoneyAmount ); InsertCommasForDollarFigure( pStr2 ); InsertDollarSignInToString( pStr2 ); @@ -7633,7 +7633,7 @@ void GetHelpTextForItem( STR16 pzStr, OBJECTTYPE *pObject, SOLDIERTYPE *pSoldier // The next is for ammunition which gets the measurement 'rnds' swprintf( pStr, L"%s [%d rnds]\n%s %1.1f %s", ItemNames[ usItem ], //Item long name - pObject->ubShotsLeft[0], //Shots left + pObject->ItemData.Ammo.ubShotsLeft[0], //Shots left gWeaponStatsDesc[ 12 ], //Weight String fWeight, //Weight GetWeightUnitString() //Weight units diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index 72603ab6..6aa191c0 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -5661,7 +5661,7 @@ void KeyRingSlotInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason ) //usOldItemIndex = gpSMCurrentMerc->inv[ uiHandPos ].usItem; //usNewItemIndex = gpItemPointer->usItem; - if ( gpItemPopupSoldier->pKeyRing[ uiKeyRing ].ubKeyID == INVALID_KEY_NUMBER || gpItemPopupSoldier->pKeyRing[ uiKeyRing ].ubKeyID == gpItemPointer->ubKeyID) + if ( gpItemPopupSoldier->pKeyRing[ uiKeyRing ].ubKeyID == INVALID_KEY_NUMBER || gpItemPopupSoldier->pKeyRing[ uiKeyRing ].ubKeyID == gpItemPointer->ItemData.Key.ubKeyID) { // Try to place here if ( ( iNumberOfKeysTaken = AddKeysToSlot( gpItemPopupSoldier, ( INT8 )uiKeyRing, gpItemPointer ) ) ) @@ -5904,7 +5904,7 @@ void SMInvMoneyButtonCallback( MOUSE_REGION * pRegion, INT32 iReason ) guiPendingOverrideEvent = A_CHANGE_TO_MOVE; HandleTacticalUI( ); - swprintf( zMoney, L"%d", gpItemPointer->uiMoneyAmount ); + swprintf( zMoney, L"%d", gpItemPointer->ItemData.Money.uiMoneyAmount ); InsertCommasForDollarFigure( zMoney ); InsertDollarSignInToString( zMoney ); @@ -5949,7 +5949,7 @@ void ConfirmationToDepositMoneyToPlayersAccount( UINT8 ubExitValue ) if ( ubExitValue == MSG_BOX_RETURN_YES ) { //add the money to the players account - AddTransactionToPlayersBook( MERC_DEPOSITED_MONEY_TO_PLAYER_ACCOUNT, gpSMCurrentMerc->ubProfile, GetWorldTotalMin(), gpItemPointer->uiMoneyAmount ); + AddTransactionToPlayersBook( MERC_DEPOSITED_MONEY_TO_PLAYER_ACCOUNT, gpSMCurrentMerc->ubProfile, GetWorldTotalMin(), gpItemPointer->ItemData.Money.uiMoneyAmount ); // dirty shopkeeper gubSkiDirtyLevel = SKI_DIRTY_LEVEL2; diff --git a/Tactical/Interface Utils.cpp b/Tactical/Interface Utils.cpp index c593d58f..c6cdaec4 100644 --- a/Tactical/Interface Utils.cpp +++ b/Tactical/Interface Utils.cpp @@ -364,7 +364,7 @@ void DrawItemUIBarEx( OBJECTTYPE *pObject, UINT8 ubStatus, INT16 sXPos, INT16 sY } else { - sValue = pObject->bStatus[ ubStatus ]; + sValue = pObject->ItemData.Generic.bStatus[ ubStatus ]; } // Adjust for ammo, other thingys.. @@ -375,7 +375,7 @@ void DrawItemUIBarEx( OBJECTTYPE *pObject, UINT8 ubStatus, INT16 sXPos, INT16 sY if ( sValue < 0 ) { - sValue = pObject->ubShotsLeft[0] * 100 / Magazine[ Item[ pObject->usItem ].ubClassIndex ].ubMagSize; + sValue = pObject->ItemData.Ammo.ubShotsLeft[0] * 100 / Magazine[ Item[ pObject->usItem ].ubClassIndex ].ubMagSize; DebugMsg ( TOPIC_JA2, DBG_LEVEL_3, String("Ammo status: shots left %d * 100 / Mag Size %d = value %d",pObject->ubShotsLeft[0],Magazine[ Item[ pObject->usItem ].ubClassIndex ].ubMagSize,sValue )); } if ( sValue > 100 ) diff --git a/Tactical/Inventory Choosing.cpp b/Tactical/Inventory Choosing.cpp index 1ee78e23..4c2a6b6d 100644 --- a/Tactical/Inventory Choosing.cpp +++ b/Tactical/Inventory Choosing.cpp @@ -553,7 +553,7 @@ void GenerateRandomEquipment( SOLDIERCREATE_STRUCT *pp, INT8 bSoldierClass, INT8 { fLAW = FALSE; } - pItem->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; + pItem->ItemData.Gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; break; case IC_AMMO: bAmmoClips = 0; @@ -563,7 +563,7 @@ void GenerateRandomEquipment( SOLDIERCREATE_STRUCT *pp, INT8 bSoldierClass, INT8 bKnifeClass = 0; break; case IC_LAUNCHER: - pItem->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; + pItem->ItemData.Gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; fGrenadeLauncher = FALSE; if (fMortar || fRPG) { @@ -660,8 +660,8 @@ void ChooseWeaponForSoldierCreateStruct( SOLDIERCREATE_STRUCT *pp, INT8 bWeaponC usGunIndex = pp->Inv[ i ].usItem; ubChanceStandardAmmo = 100 - (bWeaponClass * -9); // weapon class is negative! usAmmoIndex = RandomMagazine( usGunIndex, ubChanceStandardAmmo ); - pp->Inv[ i ].ubGunAmmoType = Magazine[Item[usAmmoIndex].ubClassIndex].ubAmmoType; - pp->Inv[ i ].usGunAmmoItem = usAmmoIndex; + pp->Inv[ i ].ItemData.Gun.ubGunAmmoType = Magazine[Item[usAmmoIndex].ubClassIndex].ubAmmoType; + pp->Inv[ i ].ItemData.Gun.usGunAmmoItem = usAmmoIndex; if ( Item[usGunIndex].fingerprintid ) { @@ -903,7 +903,7 @@ void ChooseWeaponForSoldierCreateStruct( SOLDIERCREATE_STRUCT *pp, INT8 bWeaponC DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("ChooseWeaponForSoldierCreateStruct: Set bullets")); //set bullets = to magsize including any attachments (c-mag adapters, etc) - pp->Inv[ HANDPOS ].ubGunShotsLeft = GetMagSize(&pp->Inv[ HANDPOS ]); + pp->Inv[ HANDPOS ].ItemData.Gun.ubGunShotsLeft = GetMagSize(&pp->Inv[ HANDPOS ]); DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("ChooseWeaponForSoldierCreateStruct: choose ammo")); if( bAmmoClips ) @@ -929,8 +929,8 @@ void ChooseWeaponForSoldierCreateStruct( SOLDIERCREATE_STRUCT *pp, INT8 bWeaponC //} usAmmoIndex = RandomMagazine( &pp->Inv[HANDPOS], ubChanceStandardAmmo ); - pp->Inv[ HANDPOS ].ubGunAmmoType = Magazine[Item[usAmmoIndex].ubClassIndex].ubAmmoType; - pp->Inv[ HANDPOS ].usGunAmmoItem = usAmmoIndex; + pp->Inv[ HANDPOS ].ItemData.Gun.ubGunAmmoType = Magazine[Item[usAmmoIndex].ubClassIndex].ubAmmoType; + pp->Inv[ HANDPOS ].ItemData.Gun.usGunAmmoItem = usAmmoIndex; } //Ammo @@ -2845,7 +2845,7 @@ void ReplaceExtendedGuns( SOLDIERCREATE_STRUCT *pp, INT8 bSoldierClass ) { // have to replace! but first (ugh) must store backup (b/c of attachments) CopyObj( &(pp->Inv[ uiLoop ]), &OldObj ); - CreateItem( usNewGun, OldObj.bGunStatus, &(pp->Inv[ uiLoop ]) ); + CreateItem( usNewGun, OldObj.ItemData.Gun.bGunStatus, &(pp->Inv[ uiLoop ]) ); pp->Inv[ uiLoop ].fFlags = OldObj.fFlags; // copy any valid attachments; for others, just drop them... diff --git a/Tactical/Item Types.h b/Tactical/Item Types.h index 28ce1f7e..86837226 100644 --- a/Tactical/Item Types.h +++ b/Tactical/Item Types.h @@ -84,21 +84,21 @@ typedef struct INT8 bGunAmmoStatus; // only for "attached ammo" - grenades, mortar shells UINT8 ubGunState; // SB manual recharge UINT8 ubGunUnused[MAX_OBJECTS_PER_SLOT - 6]; - }; + } Gun; struct { UINT8 ubShotsLeft[MAX_OBJECTS_PER_SLOT]; - }; + } Ammo; struct { INT8 bStatus[MAX_OBJECTS_PER_SLOT]; - }; + } Generic; struct { INT8 bMoneyStatus; UINT32 uiMoneyAmount; UINT8 ubMoneyUnused[MAX_OBJECTS_PER_SLOT - 5]; - }; + } Money; struct { // this is used by placed bombs, switches, and the action item INT8 bBombStatus; // % status @@ -106,42 +106,42 @@ typedef struct UINT16 usBombItem; // the usItem of the bomb. union { - struct - { + //struct + //{ INT8 bDelay; // >=0 values used only - }; - struct - { + //}; + //struct + //{ INT8 bFrequency; // >=0 values used only - }; - }; + //}; + } BombTrigger; UINT8 ubBombOwner; // side which placed the bomb UINT8 bActionValue;// this is used by the ACTION_ITEM fake item union { - struct - { + //struct + //{ UINT8 ubTolerance; // tolerance value for panic triggers - }; - struct - { + //}; + //struct + //{ UINT8 ubLocationID; // location value for remote non-bomb (special!) triggers - }; - }; - }; + //}; + } Area; + } Trigger; struct { INT8 bKeyStatus[ 6 ]; UINT8 ubKeyID; UINT8 ubKeyUnused[1]; - }; + } Key; struct { UINT8 ubOwnerProfile; UINT8 ubOwnerCivGroup; UINT8 ubOwnershipUnused[6]; - }; - }; + } Owner; + } ItemData; // attached objects UINT16 usAttachItem[MAX_ATTACHMENTS]; INT8 bAttachStatus[MAX_ATTACHMENTS]; diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index c31a2d25..baf559f6 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -1292,7 +1292,7 @@ BOOLEAN WeaponInHand( SOLDIERTYPE * pSoldier ) } } } - if (pSoldier->inv[HANDPOS].bGunStatus >= USABLE) + if (pSoldier->inv[HANDPOS].ItemData.Gun.bGunStatus >= USABLE) { return( TRUE ); } @@ -1381,7 +1381,7 @@ INT8 FindUsableObj( SOLDIERTYPE * pSoldier, UINT16 usItem ) for (bLoop = 0; bLoop < NUM_INV_SLOTS; bLoop++) { - if ( pSoldier->inv[bLoop].usItem == usItem && pSoldier->inv[bLoop].bStatus[0] >= USABLE ) + if ( pSoldier->inv[bLoop].usItem == usItem && pSoldier->inv[bLoop].ItemData.Generic.bStatus[0] >= USABLE ) { return( bLoop ); } @@ -1505,7 +1505,7 @@ INT8 FindAIUsableObjClass( SOLDIERTYPE * pSoldier, UINT32 usItemClass ) for (bLoop = 0; bLoop < NUM_INV_SLOTS; bLoop++) { - if ( (Item[pSoldier->inv[bLoop].usItem].usItemClass & usItemClass) && !(pSoldier->inv[bLoop].fFlags & OBJECT_AI_UNUSABLE) && (pSoldier->inv[bLoop].bStatus[0] >= USABLE ) ) + if ( (Item[pSoldier->inv[bLoop].usItem].usItemClass & usItemClass) && !(pSoldier->inv[bLoop].fFlags & OBJECT_AI_UNUSABLE) && (pSoldier->inv[bLoop].ItemData.Generic.bStatus[0] >= USABLE ) ) { if ( usItemClass == IC_GUN && EXPLOSIVE_GUN( pSoldier->inv[bLoop].usItem ) ) { @@ -1526,7 +1526,7 @@ INT8 FindAIUsableObjClassWithin( SOLDIERTYPE * pSoldier, UINT32 usItemClass, IN for (bLoop = bLower; bLoop <= bUpper; bLoop++) { - if ( (Item[pSoldier->inv[bLoop].usItem].usItemClass & usItemClass) && !(pSoldier->inv[bLoop].fFlags & OBJECT_AI_UNUSABLE) && (pSoldier->inv[bLoop].bStatus[0] >= USABLE ) ) + if ( (Item[pSoldier->inv[bLoop].usItem].usItemClass & usItemClass) && !(pSoldier->inv[bLoop].fFlags & OBJECT_AI_UNUSABLE) && (pSoldier->inv[bLoop].ItemData.Generic.bStatus[0] >= USABLE ) ) { if ( usItemClass == IC_GUN && EXPLOSIVE_GUN( pSoldier->inv[bLoop].usItem ) ) { @@ -2236,9 +2236,9 @@ UINT8 CalculateObjectWeight( OBJECTTYPE *pObject ) } // add in weight of ammo - if (Item[ pObject->usItem ].usItemClass == IC_GUN && pObject->ubGunShotsLeft > 0) + if (Item[ pObject->usItem ].usItemClass == IC_GUN && pObject->ItemData.Gun.ubGunShotsLeft > 0) { - if( 0==pObject->usGunAmmoItem ) /* Sergeant_Kolja: 2007-06-11, Fix for Creature Spit. This has no Ammo, so the old code calculated accidentally -1.6 resulting in 0xFFFF */ + if( 0==pObject->ItemData.Gun.usGunAmmoItem ) /* Sergeant_Kolja: 2007-06-11, Fix for Creature Spit. This has no Ammo, so the old code calculated accidentally -1.6 resulting in 0xFFFF */ { DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "'no ammo weight' FIX for Creatures\r\n" ); } @@ -2246,26 +2246,26 @@ UINT8 CalculateObjectWeight( OBJECTTYPE *pObject ) { //Pulmu: //Temporary calculation for minWeight - UINT32 uiMinWeight = (UINT32)((Item[ pObject->usGunAmmoItem].ubWeight / 5.0) + 0.5); - if( uiMinWeight < 1 || uiMinWeight > Item[ pObject->usGunAmmoItem].ubWeight) + UINT32 uiMinWeight = (UINT32)((Item[ pObject->ItemData.Gun.usGunAmmoItem].ubWeight / 5.0) + 0.5); + if( uiMinWeight < 1 || uiMinWeight > Item[ pObject->ItemData.Gun.usGunAmmoItem].ubWeight) { uiMinWeight = 1; } - if( uiMinWeight == Item[ pObject->usGunAmmoItem].ubWeight ) + if( uiMinWeight == Item[ pObject->ItemData.Gun.usGunAmmoItem].ubWeight ) { usWeight += uiMinWeight; } else { // WANNE: Added Pulmu's weight fix - double weight = (double)uiMinWeight + (( (double)pObject->ubGunShotsLeft / Magazine[Item[pObject->usGunAmmoItem].ubClassIndex].ubMagSize ) * ( (double)Item[ pObject->usGunAmmoItem].ubWeight - (double)uiMinWeight )) + 0.5; //Pulmu: Account for number of rounds left. + double weight = (double)uiMinWeight + (( (double)pObject->ItemData.Gun.ubGunShotsLeft / Magazine[Item[pObject->ItemData.Gun.usGunAmmoItem].ubClassIndex].ubMagSize ) * ( (double)Item[ pObject->ItemData.Gun.usGunAmmoItem].ubWeight - (double)uiMinWeight )) + 0.5; //Pulmu: Account for number of rounds left. usWeight += (UINT16)weight; } } else { - usWeight += Item[ pObject->usGunAmmoItem ].ubWeight; + usWeight += Item[ pObject->ItemData.Gun.usGunAmmoItem ].ubWeight; } } } @@ -2283,7 +2283,7 @@ UINT8 CalculateObjectWeight( OBJECTTYPE *pObject ) for( cnt = 0; cnt < pObject->ubNumberOfObjects; cnt++ ) { - if(pObject->ubShotsLeft[cnt] > 0) + if(pObject->ItemData.Ammo.ubShotsLeft[cnt] > 0) { if( uiMinWeight == Item[pObject->usItem].ubWeight ) { @@ -2291,7 +2291,7 @@ UINT8 CalculateObjectWeight( OBJECTTYPE *pObject ) } else { - weight += (double)uiMinWeight + (( (double)pObject->ubShotsLeft[cnt] / (double)Magazine[ Item[ pObject->usItem].ubClassIndex ].ubMagSize) * ( (double)Item[pObject->usItem].ubWeight - (double)uiMinWeight )); + weight += (double)uiMinWeight + (( (double)pObject->ItemData.Ammo.ubShotsLeft[cnt] / (double)Magazine[ Item[ pObject->usItem].ubClassIndex ].ubMagSize) * ( (double)Item[pObject->usItem].ubWeight - (double)uiMinWeight )); } } } @@ -2398,10 +2398,10 @@ void RemoveObjFrom( OBJECTTYPE * pObj, UINT8 ubRemoveIndex ) // shift down all the values that should be down for (ubLoop = ubRemoveIndex + 1; ubLoop < pObj->ubNumberOfObjects; ubLoop++) { - pObj->bStatus[ubLoop - 1] = pObj->bStatus[ubLoop]; + pObj->ItemData.Generic.bStatus[ubLoop - 1] = pObj->ItemData.Generic.bStatus[ubLoop]; } // and set the upper value to 0 - pObj->bStatus[pObj->ubNumberOfObjects - 1] = 0; + pObj->ItemData.Generic.bStatus[pObj->ubNumberOfObjects - 1] = 0; // make the number of objects recorded match the array pObj->ubNumberOfObjects--; } @@ -2445,7 +2445,7 @@ void GetObjFrom( OBJECTTYPE * pObj, UINT8 ubGetIndex, OBJECTTYPE * pDest ) else { pDest->usItem = pObj->usItem; - pDest->bStatus[0] = pObj->bStatus[ubGetIndex]; + pDest->ItemData.Generic.bStatus[0] = pObj->ItemData.Generic.bStatus[ubGetIndex]; pDest->ubNumberOfObjects = 1; pDest->ubWeight = CalculateObjectWeight( pDest ); RemoveObjFrom( pObj, ubGetIndex ); @@ -2462,20 +2462,20 @@ void SwapWithinObj( OBJECTTYPE * pObj, UINT8 ubIndex1, UINT8 ubIndex2 ) return; } - bTemp = pObj->bStatus[ubIndex1]; - pObj->bStatus[ubIndex1] = pObj->bStatus[ubIndex2]; - pObj->bStatus[ubIndex2] = bTemp; + bTemp = pObj->ItemData.Generic.bStatus[ubIndex1]; + pObj->ItemData.Generic.bStatus[ubIndex1] = pObj->ItemData.Generic.bStatus[ubIndex2]; + pObj->ItemData.Generic.bStatus[ubIndex2] = bTemp; } void DamageObj( OBJECTTYPE * pObj, INT8 bAmount ) { - if (bAmount >= pObj->bStatus[0]) + if (bAmount >= pObj->ItemData.Generic.bStatus[0]) { - pObj->bStatus[0] = 1; + pObj->ItemData.Generic.bStatus[0] = 1; } else { - pObj->bStatus[0] -= bAmount; + pObj->ItemData.Generic.bStatus[0] -= bAmount; } } @@ -2486,13 +2486,13 @@ void StackObjs( OBJECTTYPE * pSourceObj, OBJECTTYPE * pTargetObj, UINT8 ubNumber // copy over N status values for (ubLoop = 0; ubLoop < ubNumberToCopy; ubLoop++) { - pTargetObj->bStatus[ubLoop + pTargetObj->ubNumberOfObjects] = pSourceObj->bStatus[ubLoop ]; + pTargetObj->ItemData.Generic.bStatus[ubLoop + pTargetObj->ubNumberOfObjects] = pSourceObj->ItemData.Generic.bStatus[ubLoop ]; } // now in the source object, move the rest down N places for (ubLoop = ubNumberToCopy; ubLoop < pSourceObj->ubNumberOfObjects; ubLoop++) { - pSourceObj->bStatus[ubLoop - ubNumberToCopy] = pSourceObj->bStatus[ubLoop]; + pSourceObj->ItemData.Generic.bStatus[ubLoop - ubNumberToCopy] = pSourceObj->ItemData.Generic.bStatus[ubLoop]; } pTargetObj->ubNumberOfObjects += ubNumberToCopy; @@ -2524,20 +2524,20 @@ void CleanUpStack( OBJECTTYPE * pObj, OBJECTTYPE * pCursorObj ) { for ( bLoop = (INT8) pCursorObj->ubNumberOfObjects - 1; bLoop >= 0; bLoop-- ) { - if ( pCursorObj->bStatus[ bLoop ] > 0 ) + if ( pCursorObj->ItemData.Generic.bStatus[ bLoop ] > 0 ) { // take the points here and distribute over the lower #d items for ( bLoop2 = pObj->ubNumberOfObjects - 1; bLoop2 >= 0; bLoop2-- ) { - if ( pObj->bStatus[ bLoop2 ] < bMaxPoints ) + if ( pObj->ItemData.Generic.bStatus[ bLoop2 ] < bMaxPoints ) { - bPointsToMove = bMaxPoints - pObj->bStatus[ bLoop2 ]; - bPointsToMove = __min( bPointsToMove, pCursorObj->bStatus[ bLoop ] ); + bPointsToMove = bMaxPoints - pObj->ItemData.Generic.bStatus[ bLoop2 ]; + bPointsToMove = __min( bPointsToMove, pCursorObj->ItemData.Generic.bStatus[ bLoop ] ); - pObj->bStatus[ bLoop2 ] += bPointsToMove; + pObj->ItemData.Generic.bStatus[ bLoop2 ] += bPointsToMove; - pCursorObj->bStatus[ bLoop ] -= bPointsToMove; - if ( pCursorObj->bStatus[ bLoop ] == 0 ) + pCursorObj->ItemData.Generic.bStatus[ bLoop ] -= bPointsToMove; + if ( pCursorObj->ItemData.Generic.bStatus[ bLoop ] == 0 ) { // done! pCursorObj->ubNumberOfObjects--; @@ -2551,20 +2551,20 @@ void CleanUpStack( OBJECTTYPE * pObj, OBJECTTYPE * pCursorObj ) for ( bLoop = (INT8) pObj->ubNumberOfObjects - 1; bLoop >= 0; bLoop-- ) { - if ( pObj->bStatus[ bLoop ] > 0 ) + if ( pObj->ItemData.Generic.bStatus[ bLoop ] > 0 ) { // take the points here and distribute over the lower #d items for ( bLoop2 = bLoop - 1; bLoop2 >= 0; bLoop2-- ) { - if ( pObj->bStatus[ bLoop2 ] < bMaxPoints ) + if ( pObj->ItemData.Generic.bStatus[ bLoop2 ] < bMaxPoints ) { - bPointsToMove = bMaxPoints - pObj->bStatus[ bLoop2 ]; - bPointsToMove = __min( bPointsToMove, pObj->bStatus[ bLoop ] ); + bPointsToMove = bMaxPoints - pObj->ItemData.Generic.bStatus[ bLoop2 ]; + bPointsToMove = __min( bPointsToMove, pObj->ItemData.Generic.bStatus[ bLoop ] ); - pObj->bStatus[ bLoop2 ] += bPointsToMove; + pObj->ItemData.Generic.bStatus[ bLoop2 ] += bPointsToMove; - pObj->bStatus[ bLoop ] -= bPointsToMove; - if ( pObj->bStatus[ bLoop ] == 0 ) + pObj->ItemData.Generic.bStatus[ bLoop ] -= bPointsToMove; + if ( pObj->ItemData.Generic.bStatus[ bLoop ] == 0 ) { // done! pObj->ubNumberOfObjects--; @@ -2589,9 +2589,9 @@ BOOLEAN PlaceObjectAtObjectIndex( OBJECTTYPE * pSourceObj, OBJECTTYPE * pTargetO if (ubIndex < pTargetObj->ubNumberOfObjects) { // swap - bTemp = pSourceObj->bStatus[0]; - pSourceObj->bStatus[0] = pTargetObj->bStatus[ubIndex]; - pTargetObj->bStatus[ubIndex] = bTemp; + bTemp = pSourceObj->ItemData.Generic.bStatus[0]; + pSourceObj->ItemData.Generic.bStatus[0] = pTargetObj->ItemData.Generic.bStatus[ubIndex]; + pTargetObj->ItemData.Generic.bStatus[ubIndex] = bTemp; return( TRUE ); } else @@ -2636,19 +2636,19 @@ BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo if ( Item[ pGun->usItem ].usItemClass == IC_LAUNCHER || Item[pGun->usItem].cannon ) { DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("ReloadGun: Loading launcher - new ammo type = %d, weight = %d", pAmmo->usItem,pAmmo->ubWeight ) ); - pGun->usGunAmmoItem = pAmmo->usItem; + pGun->ItemData.Gun.usGunAmmoItem = pAmmo->usItem; if ( AttachObject( pSoldier, pGun, pAmmo ) == FALSE ) { - pGun->usGunAmmoItem = NONE; + pGun->ItemData.Gun.usGunAmmoItem = NONE; // abort return( FALSE ); } } else { - fEmptyGun = (pGun->ubGunShotsLeft == 0); + fEmptyGun = (pGun->ItemData.Gun.ubGunShotsLeft == 0); fReloadingWithStack = (pAmmo->ubNumberOfObjects > 1); - fSameAmmoType = ( pGun->ubGunAmmoType == Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType ); + fSameAmmoType = ( pGun->ItemData.Gun.ubGunAmmoType == Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType ); fSameMagazineSize = ( Magazine[ Item[ pAmmo->usItem ].ubClassIndex ].ubMagSize == GetMagSize( pGun)); if (fEmptyGun) @@ -2659,9 +2659,9 @@ BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo { // record old ammo memset( &OldAmmo, 0, sizeof( OBJECTTYPE )); - OldAmmo.usItem = pGun->usGunAmmoItem; + OldAmmo.usItem = pGun->ItemData.Gun.usGunAmmoItem; OldAmmo.ubNumberOfObjects = 1; - OldAmmo.ubShotsLeft[0] = pGun->ubGunShotsLeft; + OldAmmo.ItemData.Ammo.ubShotsLeft[0] = pGun->ItemData.Gun.ubGunShotsLeft; if (fSameMagazineSize) { @@ -2708,11 +2708,11 @@ BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo if (bReloadType == RELOAD_TOPOFF) { - ubBulletsToMove = __min( pAmmo->ubShotsLeft[0], GetMagSize(pGun) - pGun->ubGunShotsLeft ); + ubBulletsToMove = __min( pAmmo->ItemData.Ammo.ubShotsLeft[0], GetMagSize(pGun) - pGun->ItemData.Gun.ubGunShotsLeft ); } else { - ubBulletsToMove = pAmmo->ubShotsLeft[0]; + ubBulletsToMove = pAmmo->ItemData.Ammo.ubShotsLeft[0]; } } @@ -2723,11 +2723,11 @@ BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo usNewAmmoItem = FindReplacementMagazine(Weapon[pGun->usItem].ubCalibre ,GetMagSize(pGun),Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType); if (bReloadType == RELOAD_TOPOFF) { - ubBulletsToMove = __min( pAmmo->ubShotsLeft[0], GetMagSize(pGun) - pGun->ubGunShotsLeft ); + ubBulletsToMove = __min( pAmmo->ItemData.Ammo.ubShotsLeft[0], GetMagSize(pGun) - pGun->ItemData.Gun.ubGunShotsLeft ); } else { - ubBulletsToMove = __min( pAmmo->ubShotsLeft[0], GetMagSize(pGun) ); + ubBulletsToMove = __min( pAmmo->ItemData.Ammo.ubShotsLeft[0], GetMagSize(pGun) ); } } else // mag is smaller than weapon mag @@ -2737,11 +2737,11 @@ BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo usNewAmmoItem = FindReplacementMagazine(Weapon[pGun->usItem].ubCalibre ,GetMagSize(pGun),Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType); if (bReloadType == RELOAD_TOPOFF) { - ubBulletsToMove = __min( pAmmo->ubShotsLeft[0], GetMagSize(pGun) - pGun->ubGunShotsLeft ); + ubBulletsToMove = __min( pAmmo->ItemData.Ammo.ubShotsLeft[0], GetMagSize(pGun) - pGun->ItemData.Gun.ubGunShotsLeft ); } else { - ubBulletsToMove = __min( pAmmo->ubShotsLeft[0], GetMagSize(pGun)); + ubBulletsToMove = __min( pAmmo->ItemData.Ammo.ubShotsLeft[0], GetMagSize(pGun)); } } @@ -2750,15 +2750,15 @@ BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo { case RELOAD_PLACE: - pGun->ubGunShotsLeft = ubBulletsToMove; - pGun->ubGunAmmoType = Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType; - pGun->usGunAmmoItem = usNewAmmoItem; + pGun->ItemData.Gun.ubGunShotsLeft = ubBulletsToMove; + pGun->ItemData.Gun.ubGunAmmoType = Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType; + pGun->ItemData.Gun.usGunAmmoItem = usNewAmmoItem; break; case RELOAD_SWAP: - pGun->ubGunShotsLeft = ubBulletsToMove; - pGun->ubGunAmmoType = Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType; - pGun->usGunAmmoItem = usNewAmmoItem; + pGun->ItemData.Gun.ubGunShotsLeft = ubBulletsToMove; + pGun->ItemData.Gun.ubGunAmmoType = Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType; + pGun->ItemData.Gun.usGunAmmoItem = usNewAmmoItem; if (fReloadingWithStack) { // add to end of stack @@ -2794,15 +2794,15 @@ BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo return( FALSE ); } // place first ammo in gun - pGun->ubGunShotsLeft = ubBulletsToMove; - pGun->ubGunAmmoType = Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType; - pGun->usGunAmmoItem = usNewAmmoItem; + pGun->ItemData.Gun.ubGunShotsLeft = ubBulletsToMove; + pGun->ItemData.Gun.ubGunAmmoType = Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType; + pGun->ItemData.Gun.usGunAmmoItem = usNewAmmoItem; break; case RELOAD_TOPOFF: // ADD that many bullets to gun - pGun->ubGunShotsLeft += ubBulletsToMove; + pGun->ItemData.Gun.ubGunShotsLeft += ubBulletsToMove; break; } @@ -2811,8 +2811,8 @@ BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo { // remove # of bullets, delete 1 object if necessary - pAmmo->ubShotsLeft[0] -= ubBulletsToMove; - if (pAmmo->ubShotsLeft[0] == 0) + pAmmo->ItemData.Ammo.ubShotsLeft[0] -= ubBulletsToMove; + if (pAmmo->ItemData.Ammo.ubShotsLeft[0] == 0) { RemoveObjs( pAmmo, 1 ); } @@ -2842,36 +2842,52 @@ BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo DeductPoints( pSoldier, bAPs, 0 ); pGun->ubWeight = CalculateObjectWeight( pGun ); - if ( pGun->bGunAmmoStatus >= 0 ) + if ( pGun->ItemData.Gun.bGunAmmoStatus >= 0 ) { // make sure gun ammo status is 100, if gun isn't jammed - pGun->bGunAmmoStatus = 100; + pGun->ItemData.Gun.bGunAmmoStatus = 100; } - pGun->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; // Madd: reloading should automatically put cartridge in chamber + pGun->ItemData.Gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; // Madd: reloading should automatically put cartridge in chamber return( TRUE ); } +BOOLEAN UnloadGun( SOLDIERTYPE *pSoldier, OBJECTTYPE *pGun) +{ + OBJECTTYPE newObj; + CreateItem(pGun->ItemData.Gun.usGunAmmoItem, 100, &newObj); + newObj.ItemData.Ammo.ubShotsLeft[0] = pGun->ItemData.Gun.ubGunShotsLeft; + pGun->ItemData.Gun.ubGunShotsLeft = 0; + pGun->ItemData.Gun.usGunAmmoItem = NONE; + if ( !AutoPlaceObject( pSoldier, &newObj, FALSE ) ) + { // put it on the ground + AddItemToPool( pSoldier->sGridNo, &newObj, 1, pSoldier->bLevel, 0 , -1 ); + } + return TRUE; +} + BOOLEAN EmptyWeaponMagazine( OBJECTTYPE * pWeapon, OBJECTTYPE *pAmmo ) { UINT16 usReloadSound; CHECKF( pAmmo != NULL ); - if ( pWeapon->ubGunShotsLeft > 0 ) + if ( pWeapon->ItemData.Gun.ubGunShotsLeft > 0 ) { // start by erasing ammo item, just in case... DeleteObj( pAmmo ); - pAmmo->ubGunAmmoType = pWeapon->ubGunAmmoType ; - pAmmo->ubShotsLeft[0] = pWeapon->ubGunShotsLeft; - pAmmo->usItem = pWeapon->usGunAmmoItem; + // 0verhaul: The gun ammo type is supposed to be part of the magazine description. + // Besides, it is only useful for guns. For ammo this variable is just one of the ammo stack counts. + //pAmmo->ItemData.Gun.ubGunAmmoType = pWeapon->ItemData.Gun.ubGunAmmoType ; + pAmmo->ItemData.Ammo.ubShotsLeft[0] = pWeapon->ItemData.Gun.ubGunShotsLeft; + pAmmo->usItem = pWeapon->ItemData.Gun.usGunAmmoItem; pAmmo->ubNumberOfObjects = 1; - pWeapon->ubGunShotsLeft = 0; - pWeapon->ubGunAmmoType = 0; - //pWeapon->usGunAmmoItem = 0; // leaving the ammo item the same for auto-reloading purposes + pWeapon->ItemData.Gun.ubGunShotsLeft = 0; + pWeapon->ItemData.Gun.ubGunAmmoType = 0; + //pWeapon->ItemData.Gun.usGunAmmoItem = 0; // leaving the ammo item the same for auto-reloading purposes // Play some effects! usReloadSound = Weapon[ pWeapon->usItem ].sReloadSound; @@ -2899,7 +2915,7 @@ BOOLEAN ReloadLauncher( OBJECTTYPE * pLauncher, OBJECTTYPE * pAmmo ) BOOLEAN fOldAmmo; OBJECTTYPE OldAmmo; - if (pLauncher->ubGunShotsLeft == 0) + if (pLauncher->ItemData.Gun.ubGunShotsLeft == 0) { fOldAmmo = FALSE; } @@ -2913,16 +2929,16 @@ BOOLEAN ReloadLauncher( OBJECTTYPE * pLauncher, OBJECTTYPE * pAmmo ) // otherwise temporarily store the launcher's old ammo memset( &OldAmmo, 0, sizeof( OBJECTTYPE )); fOldAmmo = TRUE; - OldAmmo.usItem = pLauncher->usGunAmmoItem; + OldAmmo.usItem = pLauncher->ItemData.Gun.usGunAmmoItem; OldAmmo.ubNumberOfObjects = 1; - OldAmmo.bStatus[0] = pLauncher->bGunAmmoStatus; + OldAmmo.bStatus[0] = pLauncher->ItemData.Gun.bGunAmmoStatus; } // put the new ammo in the gun - pLauncher->usGunAmmoItem = pAmmo->usItem; - pLauncher->ubGunShotsLeft = 1; - pLauncher->ubGunAmmoType = AMMO_GRENADE; - pLauncher->bGunAmmoStatus = pAmmo->bStatus[0]; + pLauncher->ItemData.Gun.usGunAmmoItem = pAmmo->usItem; + pLauncher->ItemData.Gun.ubGunShotsLeft = 1; + pLauncher->ItemData.Gun.ubGunAmmoType = AMMO_GRENADE; + pLauncher->ItemData.Gun.bGunAmmoStatus = pAmmo->ItemData.Generic.bStatus[0]; if (fOldAmmo) @@ -2975,14 +2991,14 @@ INT8 FindAmmoToReload( SOLDIERTYPE * pSoldier, INT8 bWeaponIn, INT8 bExcludeSlot pObj = &(pSoldier->inv[bWeaponIn]); // manual recharge - if (pObj->ubGunShotsLeft && !(pObj->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) + if (pObj->ItemData.Gun.ubGunShotsLeft && !(pObj->ItemData.Gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) return bWeaponIn; // if ( Item[pObj->usItem].usItemClass == IC_GUN && !Item[pObj->usItem].cannon ) { // look for same ammo as before - bSlot = FindObjExcludingSlot( pSoldier, pObj->usGunAmmoItem, bExcludeSlot ); + bSlot = FindObjExcludingSlot( pSoldier, pObj->ItemData.Gun.usGunAmmoItem, bExcludeSlot ); if (bSlot != NO_SLOT) { // reload using this ammo! @@ -3044,9 +3060,9 @@ BOOLEAN AutoReload( SOLDIERTYPE * pSoldier ) pObj = &(pSoldier->inv[HANDPOS]); // manual recharge - if (pObj->ubGunShotsLeft && !(pObj->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) + if (pObj->ItemData.Gun.ubGunShotsLeft && !(pObj->ItemData.Gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) { - pObj->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; + pObj->ItemData.Gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; DeductPoints(pSoldier, Weapon[Item[(pObj)->usItem].ubClassIndex].APsToReloadManually, 0); @@ -3056,9 +3072,9 @@ BOOLEAN AutoReload( SOLDIERTYPE * pSoldier ) { pObj2 = &(pSoldier->inv[SECONDHANDPOS]); - if (pObj2->ubGunShotsLeft && !(pObj2->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) + if (pObj2->ItemData.Gun.ubGunShotsLeft && !(pObj2->ItemData.Gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) { - pObj2->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; + pObj2->ItemData.Gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; PlayJA2Sample( Weapon[ Item[pObj2->usItem].ubClassIndex ].ManualReloadSound, RATE_11025, SoundVolume( HIGHVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ) ); } } @@ -3071,9 +3087,9 @@ BOOLEAN AutoReload( SOLDIERTYPE * pSoldier ) { pObj2 = &(pSoldier->inv[SECONDHANDPOS]); - if (pObj2->ubGunShotsLeft && !(pObj2->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) + if (pObj2->ItemData.Gun.ubGunShotsLeft && !(pObj2->ItemData.Gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) { - pObj2->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; + pObj2->ItemData.Gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; DeductPoints(pSoldier, Weapon[Item[(pObj2)->usItem].ubClassIndex].APsToReloadManually, 0); @@ -3206,11 +3222,11 @@ void PerformAttachmentComboMerge( OBJECTTYPE * pObj, INT8 bAttachmentComboMerge pObj->bAttachStatus[ bAttachPos ] = 0; } - uiStatusTotal += pObj->bStatus[ 0 ]; + uiStatusTotal += pObj->ItemData.Generic.bStatus[ 0 ]; bNumStatusContributors++; pObj->usItem = AttachmentComboMerge[ bAttachmentComboMerge ].usResult; - pObj->bStatus[ 0 ] = (INT8) (uiStatusTotal / bNumStatusContributors ); + pObj->ItemData.Generic.bStatus[ 0 ] = (INT8) (uiStatusTotal / bNumStatusContributors ); } @@ -3295,7 +3311,7 @@ BOOLEAN AttachObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pTargetObj, OBJECTTYP if ( fValidLaunchable ) { - pTargetObj->usGunAmmoItem = pAttachment->usItem; + pTargetObj->ItemData.Gun.usGunAmmoItem = pAttachment->usItem; } } } @@ -3353,7 +3369,7 @@ BOOLEAN AttachObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pTargetObj, OBJECTTYP } pTargetObj->usAttachItem[bAttachPos] = pAttachment->usItem; - pTargetObj->bAttachStatus[bAttachPos] = pAttachment->bStatus[0]; + pTargetObj->bAttachStatus[bAttachPos] = pAttachment->ItemData.Generic.bStatus[0]; if (Item[pAttachment->usItem].grenadelauncher ) { @@ -3453,19 +3469,11 @@ BOOLEAN AttachObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pTargetObj, OBJECTTYP //Madd: note that use_item cannot produce two different items!!! so it doesn't use usResult2 //Madd: unload guns after merge if ammo caliber or mag size don't match - if ( Item[pTargetObj->usItem].usItemClass == IC_GUN && pTargetObj->usGunAmmoItem != NONE && pTargetObj->ubGunShotsLeft > 0 ) + if ( Item[pTargetObj->usItem].usItemClass == IC_GUN && pTargetObj->ItemData.Gun.usGunAmmoItem != NONE && pTargetObj->ItemData.Gun.ubGunShotsLeft > 0 ) { - if ( Item[usResult].usItemClass != IC_GUN || Weapon[Item[usResult].ubClassIndex].ubCalibre != Weapon[Item[pTargetObj->usItem].ubClassIndex].ubCalibre || pTargetObj->ubGunShotsLeft > Weapon[Item[usResult].ubClassIndex].ubMagSize ) + if ( Item[usResult].usItemClass != IC_GUN || Weapon[Item[usResult].ubClassIndex].ubCalibre != Weapon[Item[pTargetObj->usItem].ubClassIndex].ubCalibre || pTargetObj->ItemData.Gun.ubGunShotsLeft > Weapon[Item[usResult].ubClassIndex].ubMagSize ) { // item types/calibers/magazines don't match, spit out old ammo - OBJECTTYPE newObj; - CreateItem(pTargetObj->usGunAmmoItem, 100, &newObj); - newObj.ubShotsLeft[0] = pTargetObj->ubGunShotsLeft; - pTargetObj->ubGunShotsLeft = 0; - pTargetObj->usGunAmmoItem = NONE; - if ( !AutoPlaceObject( pSoldier, &newObj, FALSE ) ) - { // put it on the ground - AddItemToPool( pSoldier->sGridNo, &newObj, 1, pSoldier->bLevel, 0 , -1 ); - } + UnloadGun( pSoldier, pTargetObj); } } @@ -3517,10 +3525,10 @@ BOOLEAN AttachObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pTargetObj, OBJECTTYP // count down through # of attaching items and add to status of item in position 0 for (bLoop = pAttachment->ubNumberOfObjects - 1; bLoop >= 0; bLoop--) { - if (pTargetObj->bStatus[0] + pAttachment->bStatus[bLoop] <= ubLimit) + if (pTargetObj->ItemData.Generic.bStatus[0] + pAttachment->ItemData.Generic.bStatus[bLoop] <= ubLimit) { // consume this one totally and continue - pTargetObj->bStatus[0] += pAttachment->bStatus[bLoop]; + pTargetObj->ItemData.Generic.bStatus[0] += pAttachment->ItemData.Generic.bStatus[bLoop]; RemoveObjFrom( pAttachment, bLoop ); // reset loop limit bLoop = pAttachment->ubNumberOfObjects; // add 1 to counteract the -1 from the loop @@ -3528,8 +3536,8 @@ BOOLEAN AttachObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pTargetObj, OBJECTTYP else { // add part of this one and then we're done - pAttachment->bStatus[bLoop] -= (ubLimit - pTargetObj->bStatus[0]); - pTargetObj->bStatus[0] = ubLimit; + pAttachment->ItemData.Generic.bStatus[bLoop] -= (ubLimit - pTargetObj->ItemData.Generic.bStatus[0]); + pTargetObj->ItemData.Generic.bStatus[0] = ubLimit; break; } } @@ -3580,19 +3588,11 @@ BOOLEAN AttachObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pTargetObj, OBJECTTYP //Madd: usResult2 only works for standard merges -> item1 + item2 = item3 + item4 //Madd: unload guns after merge if ammo caliber or mag size don't match - if ( Item[pTargetObj->usItem].usItemClass == IC_GUN && pTargetObj->usGunAmmoItem != NONE && pTargetObj->ubGunShotsLeft > 0 ) + if ( Item[pTargetObj->usItem].usItemClass == IC_GUN && pTargetObj->ItemData.Gun.usGunAmmoItem != NONE && pTargetObj->ItemData.Gun.ubGunShotsLeft > 0 ) { - if ( Item[usResult].usItemClass != IC_GUN || Weapon[Item[usResult].ubClassIndex].ubCalibre != Weapon[Item[pTargetObj->usItem].ubClassIndex].ubCalibre || pTargetObj->ubGunShotsLeft > Weapon[Item[usResult].ubClassIndex].ubMagSize ) + if ( Item[usResult].usItemClass != IC_GUN || Weapon[Item[usResult].ubClassIndex].ubCalibre != Weapon[Item[pTargetObj->usItem].ubClassIndex].ubCalibre || pTargetObj->ItemData.Gun.ubGunShotsLeft > Weapon[Item[usResult].ubClassIndex].ubMagSize ) { // item types/calibers/magazines don't match, spit out old ammo - OBJECTTYPE newObj; - CreateItem(pTargetObj->usGunAmmoItem, 100, &newObj); - newObj.ubShotsLeft[0] = pTargetObj->ubGunShotsLeft; - pTargetObj->ubGunShotsLeft = 0; - pTargetObj->usGunAmmoItem = NONE; - if ( !AutoPlaceObject( pSoldier, &newObj, FALSE ) ) - { // put it on the ground - AddItemToPool( pSoldier->sGridNo, &newObj, 1, pSoldier->bLevel, 0 , -1 ); - } + UnloadGun( pSoldier, pTargetObj); } } @@ -3621,7 +3621,7 @@ BOOLEAN AttachObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pTargetObj, OBJECTTYP pTargetObj->usItem = usResult; if ( ubType != TREAT_ARMOUR ) { - pTargetObj->bStatus[0] = (pTargetObj->bStatus[0] + pAttachment->bStatus[0]) / 2; + pTargetObj->ItemData.Generic.bStatus[0] = (pTargetObj->ItemData.Generic.bStatus[0] + pAttachment->ItemData.Generic.bStatus[0]) / 2; } pTargetObj->ubWeight = CalculateObjectWeight( pTargetObj ); @@ -3631,19 +3631,11 @@ BOOLEAN AttachObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pTargetObj, OBJECTTYP //Madd: usResult2 is what the original attachment/source item turns into //Madd: unload guns after merge if ammo caliber or mag size don't match - if ( Item[pAttachment->usItem].usItemClass == IC_GUN && pAttachment->usGunAmmoItem != NONE && pAttachment->ubGunShotsLeft > 0 ) + if ( Item[pAttachment->usItem].usItemClass == IC_GUN && pAttachment->ItemData.Gun.usGunAmmoItem != NONE && pAttachment->ItemData.Gun.ubGunShotsLeft > 0 ) { - if ( Item[usResult2].usItemClass != IC_GUN || Weapon[Item[usResult2].ubClassIndex].ubCalibre != Weapon[Item[pAttachment->usItem].ubClassIndex].ubCalibre || pAttachment->ubGunShotsLeft > Weapon[Item[usResult2].ubClassIndex].ubMagSize ) + if ( Item[usResult2].usItemClass != IC_GUN || Weapon[Item[usResult2].ubClassIndex].ubCalibre != Weapon[Item[pAttachment->usItem].ubClassIndex].ubCalibre || pAttachment->ItemData.Gun.ubGunShotsLeft > Weapon[Item[usResult2].ubClassIndex].ubMagSize ) { // item types/calibers/magazines don't match, spit out old ammo - OBJECTTYPE newObj; - CreateItem(pAttachment->usGunAmmoItem, 100, &newObj); - newObj.ubShotsLeft[0] = pAttachment->ubGunShotsLeft; - pAttachment->ubGunShotsLeft = 0; - pAttachment->usGunAmmoItem = NONE; - if ( !AutoPlaceObject( pSoldier, &newObj, FALSE ) ) - { // put it on the ground - AddItemToPool( pSoldier->sGridNo, &newObj, 1, pSoldier->bLevel, 0 , -1 ); - } + UnloadGun( pSoldier, pAttachment); } } @@ -3674,7 +3666,7 @@ BOOLEAN AttachObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pTargetObj, OBJECTTYP pAttachment->usItem = usResult2; if ( ubType != TREAT_ARMOUR ) { - pAttachment->bStatus[0] = (pAttachment->bStatus[0] + pTargetObj->bStatus[0]) / 2; + pAttachment->ItemData.Generic.bStatus[0] = (pAttachment->ItemData.Generic.bStatus[0] + pTargetObj->ItemData.Generic.bStatus[0]) / 2; } pAttachment->ubWeight = CalculateObjectWeight( pAttachment ); } @@ -3854,10 +3846,10 @@ BOOLEAN PlaceObject( SOLDIERTYPE * pSoldier, INT8 bPos, OBJECTTYPE * pObj ) if ( Item[ pObj->usItem ].usItemClass == IC_KEY && pSoldier->uiStatusFlags & SOLDIER_PC ) { - if ( KeyTable[ pObj->ubKeyID ].usDateFound == 0 ) + if ( KeyTable[ pObj->ItemData.Key.ubKeyID ].usDateFound == 0 ) { - KeyTable[ pObj->ubKeyID ].usDateFound = (UINT16) GetWorldDay(); - KeyTable[ pObj->ubKeyID ].usSectorFound = SECTOR( pSoldier->sSectorX, pSoldier->sSectorY ); + KeyTable[ pObj->ItemData.Key.ubKeyID ].usDateFound = (UINT16) GetWorldDay(); + KeyTable[ pObj->ItemData.Key.ubKeyID ].usSectorFound = SECTOR( pSoldier->sSectorX, pSoldier->sSectorY ); } } @@ -3912,7 +3904,7 @@ BOOLEAN PlaceObject( SOLDIERTYPE * pSoldier, INT8 bPos, OBJECTTYPE * pObj ) // in the InSlot copy, zero out all the objects we didn't drop for (ubLoop = ubNumberToDrop; ubLoop < pObj->ubNumberOfObjects; ubLoop++) { - pInSlot->bStatus[ubLoop] = 0; + pInSlot->ItemData.Generic.bStatus[ubLoop] = 0; } } pInSlot->ubNumberOfObjects = ubNumberToDrop; @@ -3940,7 +3932,7 @@ BOOLEAN PlaceObject( SOLDIERTYPE * pSoldier, INT8 bPos, OBJECTTYPE * pObj ) { // replacement/reloading/merging/stacking // keys have an additional check for key ID being the same - if ( (pObj->usItem == pInSlot->usItem) && ( Item[ pObj->usItem ].usItemClass != IC_KEY || pObj->ubKeyID == pInSlot->ubKeyID ) ) + if ( (pObj->usItem == pInSlot->usItem) && ( Item[ pObj->usItem ].usItemClass != IC_KEY || pObj->ItemData.Key.ubKeyID == pInSlot->ItemData.Key.ubKeyID ) ) { if (Item[ pObj->usItem ].usItemClass == IC_MONEY) { @@ -3950,16 +3942,16 @@ BOOLEAN PlaceObject( SOLDIERTYPE * pSoldier, INT8 bPos, OBJECTTYPE * pObj ) // always allow money to be combined! // IGNORE STATUS! - if (pInSlot->uiMoneyAmount + pObj->uiMoneyAmount > uiMoneyMax) + if (pInSlot->ItemData.Money.uiMoneyAmount + pObj->ItemData.Money.uiMoneyAmount > uiMoneyMax) { // remove X dollars - pObj->uiMoneyAmount -= (uiMoneyMax - pInSlot->uiMoneyAmount); + pObj->ItemData.Money.uiMoneyAmount -= (uiMoneyMax - pInSlot->ItemData.Money.uiMoneyAmount); // set in slot to maximum - pInSlot->uiMoneyAmount = uiMoneyMax; + pInSlot->ItemData.Money.uiMoneyAmount = uiMoneyMax; } else { - pInSlot->uiMoneyAmount += pObj->uiMoneyAmount; + pInSlot->ItemData.Money.uiMoneyAmount += pObj->ItemData.Money.uiMoneyAmount; DeleteObj( pObj ); /* if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE ) @@ -4237,7 +4229,7 @@ BOOLEAN InternalAutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOL } if ( bSlot != bExcludeSlot ) { - if ( ( (Item[ pObj->usItem ].usItemClass == IC_MONEY) && pSoldier->inv[ bSlot ].uiMoneyAmount < MoneySlotLimit( bSlot ) ) || (Item[ pObj->usItem ].usItemClass != IC_MONEY && pSoldier->inv[bSlot].ubNumberOfObjects < ItemSlotLimit( pObj->usItem, bSlot ) ) ) + if ( ( (Item[ pObj->usItem ].usItemClass == IC_MONEY) && pSoldier->inv[ bSlot ].ItemData.Money.uiMoneyAmount < MoneySlotLimit( bSlot ) ) || (Item[ pObj->usItem ].usItemClass != IC_MONEY && pSoldier->inv[bSlot].ubNumberOfObjects < ItemSlotLimit( pObj->usItem, bSlot ) ) ) { // NEW: If in SKI, don't auto-place anything into a stackable slot that's currently hatched out! Such slots // will disappear in their entirety if sold/moved, causing anything added through here to vanish also! @@ -4392,10 +4384,10 @@ UINT8 AddKeysToSlot( SOLDIERTYPE * pSoldier, INT8 bKeyRingPosition, OBJECTTYPE * if ( pSoldier->uiStatusFlags & SOLDIER_PC ) // redundant but what the hey { - if ( KeyTable[ pObj->ubKeyID ].usDateFound == 0 ) + if ( KeyTable[ pObj->ItemData.Key.ubKeyID ].usDateFound == 0 ) { - KeyTable[ pObj->ubKeyID ].usDateFound = (UINT16) GetWorldDay(); - KeyTable[ pObj->ubKeyID ].usSectorFound = SECTOR( pSoldier->sSectorX, pSoldier->sSectorY ); + KeyTable[ pObj->ItemData.Key.ubKeyID ].usDateFound = (UINT16) GetWorldDay(); + KeyTable[ pObj->ItemData.Key.ubKeyID ].usSectorFound = SECTOR( pSoldier->sSectorX, pSoldier->sSectorY ); } } @@ -4410,7 +4402,7 @@ UINT8 AddKeysToSlot( SOLDIERTYPE * pSoldier, INT8 bKeyRingPosition, OBJECTTYPE * if( pSoldier->pKeyRing[ bKeyRingPosition ].ubNumber == 0 ) { - pSoldier->pKeyRing[ bKeyRingPosition ].ubKeyID = pObj->ubKeyID; + pSoldier->pKeyRing[ bKeyRingPosition ].ubKeyID = pObj->ItemData.Key.ubKeyID; } // return number used @@ -4421,7 +4413,7 @@ UINT8 AddKeysToSlot( SOLDIERTYPE * pSoldier, INT8 bKeyRingPosition, OBJECTTYPE * // check if( pSoldier->pKeyRing[ bKeyRingPosition ].ubNumber == 0 ) { - pSoldier->pKeyRing[ bKeyRingPosition ].ubKeyID = pObj->ubKeyID; + pSoldier->pKeyRing[ bKeyRingPosition ].ubKeyID = pObj->ItemData.Key.ubKeyID; } pSoldier->pKeyRing[ bKeyRingPosition ].ubNumber += pObj->ubNumberOfObjects; @@ -4440,7 +4432,7 @@ UINT8 SwapKeysToSlot( SOLDIERTYPE * pSoldier, INT8 bKeyRingPosition, OBJECTTYPE CreateKeyObject( &TempObj, pSoldier->pKeyRing[ bKeyRingPosition ].ubNumber, pSoldier->pKeyRing[ bKeyRingPosition ].ubKeyID ); pSoldier->pKeyRing[ bKeyRingPosition ].ubNumber = pObj->ubNumberOfObjects; - pSoldier->pKeyRing[ bKeyRingPosition ].ubKeyID = pObj->ubKeyID; + pSoldier->pKeyRing[ bKeyRingPosition ].ubKeyID = pObj->ItemData.Key.ubKeyID; // swap params? CopyObj( &TempObj, pObj ); @@ -4456,7 +4448,7 @@ BOOLEAN CreateKeyObject( OBJECTTYPE * pObj , UINT8 ubNumberOfKeys, UINT8 ubKeyID fRet = CreateItems( (UINT16) (FIRST_KEY + LockTable[ ubKeyID ].usKeyItem), 100, ubNumberOfKeys, pObj ); if (fRet) { - pObj->ubKeyID = ubKeyID; + pObj->ItemData.Key.ubKeyID = ubKeyID; } //fRet = CreateItems( (UINT16)(ubKeyIdValue + FIRST_KEY) , 100, ubNumberOfKeys, pObj ) //return( ); @@ -4493,7 +4485,7 @@ UINT16 TotalPoints( OBJECTTYPE * pObj ) for (ubLoop = 0; ubLoop < pObj->ubNumberOfObjects; ubLoop++) { - usPoints += pObj->bStatus[ubLoop]; + usPoints += pObj->ItemData.Generic.bStatus[ubLoop]; } return( usPoints ); } @@ -4507,21 +4499,21 @@ UINT16 UseKitPoints( OBJECTTYPE * pObj, UINT16 usPoints, SOLDIERTYPE *pSoldier ) for (bLoop = pObj->ubNumberOfObjects - 1; bLoop >= 0; bLoop--) { - if (Item[pObj->usItem].percentstatusdrainreduction > 0 && ((usPoints * (100 - Item[pObj->usItem].percentstatusdrainreduction))/100) < pObj->bStatus[bLoop] ) + if (Item[pObj->usItem].percentstatusdrainreduction > 0 && ((usPoints * (100 - Item[pObj->usItem].percentstatusdrainreduction))/100) < pObj->ItemData.Generic.bStatus[bLoop] ) { - pObj->bStatus[bLoop] -= (INT8) ((usPoints * (100 - Item[pObj->usItem].percentstatusdrainreduction ) )/100); + pObj->ItemData.Generic.bStatus[bLoop] -= (INT8) ((usPoints * (100 - Item[pObj->usItem].percentstatusdrainreduction ) )/100); return( usOriginalPoints ); } - else if (usPoints < (UINT16) pObj->bStatus[bLoop]) + else if (usPoints < (UINT16) pObj->ItemData.Generic.bStatus[bLoop]) { - pObj->bStatus[bLoop] -= (INT8) usPoints; + pObj->ItemData.Generic.bStatus[bLoop] -= (INT8) usPoints; return( usOriginalPoints ); } else { // consume this kit totally - usPoints -= pObj->bStatus[bLoop]; - pObj->bStatus[bLoop] = 0; + usPoints -= pObj->ItemData.Generic.bStatus[bLoop]; + pObj->ItemData.Generic.bStatus[bLoop] = 0; pObj->ubNumberOfObjects--; } @@ -4988,28 +4980,28 @@ BOOLEAN CreateGun( UINT16 usItem, INT8 bStatus, OBJECTTYPE * pObj ) memset( pObj, 0, sizeof( OBJECTTYPE ) ); pObj->usItem = usItem; pObj->ubNumberOfObjects = 1; - pObj->bGunStatus = bStatus; + pObj->ItemData.Gun.bGunStatus = bStatus; pObj->ubImprintID = NO_PROFILE; pObj->ubWeight = CalculateObjectWeight( pObj ); if (Weapon[ usItem ].ubWeaponClass == MONSTERCLASS) { - pObj->ubGunShotsLeft = GetMagSize(pObj); - pObj->ubGunAmmoType = AMMO_MONSTER; + pObj->ItemData.Gun.ubGunShotsLeft = GetMagSize(pObj); + pObj->ItemData.Gun.ubGunAmmoType = AMMO_MONSTER; } else if ( EXPLOSIVE_GUN( usItem ) ) { if ( Item[usItem].singleshotrocketlauncher ) { - pObj->ubGunShotsLeft = 1; + pObj->ItemData.Gun.ubGunShotsLeft = 1; } else { // cannon - pObj->ubGunShotsLeft = 0; + pObj->ItemData.Gun.ubGunShotsLeft = 0; } - pObj->bGunAmmoStatus = 100; - pObj->ubGunAmmoType = 0; + pObj->ItemData.Gun.bGunAmmoStatus = 100; + pObj->ItemData.Gun.ubGunAmmoType = 0; } else { @@ -5022,11 +5014,11 @@ BOOLEAN CreateGun( UINT16 usItem, INT8 bStatus, OBJECTTYPE * pObj ) } else { - pObj->usGunAmmoItem = usAmmo; - pObj->ubGunAmmoType = Magazine[ Item[ usAmmo ].ubClassIndex].ubAmmoType; - pObj->bGunAmmoStatus = 100; - pObj->ubGunShotsLeft = Magazine[ Item[ usAmmo ].ubClassIndex ].ubMagSize; - pObj->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; // Madd: new guns should have cartridge in chamber + pObj->ItemData.Gun.usGunAmmoItem = usAmmo; + pObj->ItemData.Gun.ubGunAmmoType = Magazine[ Item[ usAmmo ].ubClassIndex].ubAmmoType; + pObj->ItemData.Gun.bGunAmmoStatus = 100; + pObj->ItemData.Gun.ubGunShotsLeft = Magazine[ Item[ usAmmo ].ubClassIndex ].ubMagSize; + pObj->ItemData.Gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; // Madd: new guns should have cartridge in chamber /* if (usItem == CAWS) { @@ -5051,7 +5043,7 @@ BOOLEAN CreateMagazine( UINT16 usItem, OBJECTTYPE * pObj ) memset( pObj, 0, sizeof( OBJECTTYPE ) ); pObj->usItem = usItem; pObj->ubNumberOfObjects = 1; - pObj->ubShotsLeft[0] = Magazine[ Item[usItem].ubClassIndex ].ubMagSize; + pObj->ItemData.Ammo.ubShotsLeft[0] = Magazine[ Item[usItem].ubClassIndex ].ubMagSize; pObj->ubWeight = CalculateObjectWeight( pObj ); DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("CreateMagazine: done")); @@ -5084,12 +5076,12 @@ BOOLEAN CreateItem( UINT16 usItem, INT8 bStatus, OBJECTTYPE * pObj ) { // special case... always set status to 100 when creating // and use status value to determine amount! - pObj->bStatus[0] = 100; - pObj->uiMoneyAmount = bStatus * 50; + pObj->ItemData.Generic.bStatus[0] = 100; + pObj->ItemData.Money.uiMoneyAmount = bStatus * 50; } else { - pObj->bStatus[0] = bStatus; + pObj->ItemData.Generic.bStatus[0] = bStatus; } pObj->ubWeight = CalculateObjectWeight( pObj ); fRet = TRUE; @@ -5133,7 +5125,7 @@ BOOLEAN CreateItems( UINT16 usItem, INT8 bStatus, UINT8 ubNumber, OBJECTTYPE * p // we reference status[0] here because the status value might actually be a // # of rounds of ammo, in which case the value won't be the bStatus value // passed in. - pObj->bStatus[ubLoop] = pObj->bStatus[0]; + pObj->ItemData.Generic.bStatus[ubLoop] = pObj->ItemData.Generic.bStatus[0]; } pObj->ubNumberOfObjects = ubNumber; pObj->ubWeight *= ubNumber; @@ -5149,7 +5141,7 @@ BOOLEAN CreateMoney( UINT32 uiMoney, OBJECTTYPE * pObj ) fOk = CreateItem( MONEY, 100, pObj ); if (fOk) { - pObj->uiMoneyAmount = uiMoney; + pObj->ItemData.Money.uiMoneyAmount = uiMoney; } return( fOk ); } @@ -5163,7 +5155,7 @@ BOOLEAN ArmBomb( OBJECTTYPE * pObj, INT8 bSetting ) if (pObj->usItem == ACTION_ITEM) { - switch( pObj->bActionValue ) + switch( pObj->ItemData.Trigger.bActionValue ) { case ACTION_ITEM_SMALL_PIT: case ACTION_ITEM_LARGE_PIT: @@ -5209,30 +5201,30 @@ BOOLEAN ArmBomb( OBJECTTYPE * pObj, INT8 bSetting ) if (fRemote) { - pObj->bDetonatorType = BOMB_REMOTE; - pObj->bFrequency = bSetting; + pObj->ItemData.Trigger.bDetonatorType = BOMB_REMOTE; + pObj->ItemData.Trigger.BombTrigger.bFrequency = bSetting; } else if (fPressure) { - pObj->bDetonatorType = BOMB_PRESSURE; - pObj->bFrequency = 0; + pObj->ItemData.Trigger.bDetonatorType = BOMB_PRESSURE; + pObj->ItemData.Trigger.BombTrigger.bFrequency = 0; } else if (fTimed) { - pObj->bDetonatorType = BOMB_TIMED; + pObj->ItemData.Trigger.bDetonatorType = BOMB_TIMED; // In realtime the player could choose to put down a bomb right before a turn expires, SO // add 1 to the setting in RT - pObj->bDelay = bSetting; + pObj->ItemData.Trigger.BombTrigger.bDelay = bSetting; if ( !(gTacticalStatus.uiFlags & TURNBASED && gTacticalStatus.uiFlags & INCOMBAT) ) { - pObj->bDelay++; + pObj->ItemData.Trigger.BombTrigger.bDelay++; } } else if (fSwitch) { - pObj->bDetonatorType = BOMB_SWITCH; - pObj->bFrequency = bSetting; + pObj->ItemData.Trigger.bDetonatorType = BOMB_SWITCH; + pObj->ItemData.Trigger.BombTrigger.bFrequency = bSetting; } else { @@ -5240,7 +5232,7 @@ BOOLEAN ArmBomb( OBJECTTYPE * pObj, INT8 bSetting ) } pObj->fFlags |= OBJECT_ARMED_BOMB; - pObj->usBombItem = pObj->usItem; + pObj->ItemData.Trigger.usBombItem = pObj->usItem; return( TRUE ); } @@ -5359,12 +5351,12 @@ BOOLEAN PlaceObjectInSoldierProfile( UINT8 ubProfile, OBJECTTYPE *pObject ) BOOLEAN fReturnVal = FALSE; usItem = pObject->usItem; - bStatus = pObject->bStatus[0]; + bStatus = pObject->ItemData.Generic.bStatus[0]; pSoldier = FindSoldierByProfileID( ubProfile, FALSE ); if ( Item[ usItem ].usItemClass == IC_MONEY && gMercProfiles[ ubProfile ].uiMoney > 0 ) { - gMercProfiles[ ubProfile ].uiMoney += pObject->uiMoneyAmount; + gMercProfiles[ ubProfile ].uiMoney += pObject->ItemData.Money.uiMoneyAmount; SetMoneyInSoldierProfile( ubProfile, gMercProfiles[ ubProfile ].uiMoney ); return( TRUE ); } @@ -5377,7 +5369,7 @@ BOOLEAN PlaceObjectInSoldierProfile( UINT8 ubProfile, OBJECTTYPE *pObject ) // CJC: Deal with money by putting money into # stored in profile if ( Item[ usItem ].usItemClass == IC_MONEY ) { - gMercProfiles[ ubProfile ].uiMoney += pObject->uiMoneyAmount; + gMercProfiles[ ubProfile ].uiMoney += pObject->ItemData.Money.uiMoneyAmount; // change any gold/silver to money usItem = MONEY; } @@ -5604,7 +5596,7 @@ BOOLEAN DamageItem( OBJECTTYPE * pObject, INT32 iDamage, BOOLEAN fOnGround ) { // if the status of the item is negative then it's trapped/jammed; // leave it alone - if (pObject->usItem != NOTHING && pObject->bStatus[bLoop] > 0) + if (pObject->usItem != NOTHING && pObject->ItemData.Generic.bStatus[bLoop] > 0) { bDamage = CheckItemForDamage( pObject->usItem, iDamage ); switch( pObject->usItem ) @@ -5616,7 +5608,7 @@ BOOLEAN DamageItem( OBJECTTYPE * pObject, INT32 iDamage, BOOLEAN fOnGround ) if ( PreRandom( bDamage ) > 5 ) { // smash! - bDamage = pObject->bStatus[ bLoop ]; + bDamage = pObject->ItemData.Generic.bStatus[ bLoop ]; } break; default: @@ -5627,29 +5619,29 @@ BOOLEAN DamageItem( OBJECTTYPE * pObject, INT32 iDamage, BOOLEAN fOnGround ) if ( PreRandom( 100 ) < (UINT32) bDamage ) { // destroy clip completely - pObject->bStatus[ bLoop ] = 1; + pObject->ItemData.Generic.bStatus[ bLoop ] = 1; } } else { - pObject->bStatus[bLoop] -= bDamage; - if (pObject->bStatus[bLoop] < 1) + pObject->ItemData.Generic.bStatus[bLoop] -= bDamage; + if (pObject->ItemData.Generic.bStatus[bLoop] < 1) { - pObject->bStatus[bLoop] = 1; + pObject->ItemData.Generic.bStatus[bLoop] = 1; } } // I don't think we increase viewrange based on items any more // FUN STUFF! Check for explosives going off as a result! if (Item[pObject->usItem].usItemClass & IC_EXPLOSV) { - if (CheckForChainReaction( pObject->usItem, pObject->bStatus[bLoop], bDamage, fOnGround )) + if (CheckForChainReaction( pObject->usItem, pObject->ItemData.Generic.bStatus[bLoop], bDamage, fOnGround )) { return( TRUE ); } } // remove item from index AFTER checking explosions because need item data for explosion! - if ( pObject->bStatus[bLoop] == 1 ) + if ( pObject->ItemData.Generic.bStatus[bLoop] == 1 ) { if ( pObject->ubNumberOfObjects > 1 ) { @@ -5762,7 +5754,7 @@ BOOLEAN DamageItemOnGround( OBJECTTYPE * pObject, INT16 sGridNo, INT8 bLevel, IN // Remove item! return( TRUE ); } - else if ( (pObject->ubNumberOfObjects < 2) && (pObject->bStatus[0] < USABLE) ) + else if ( (pObject->ubNumberOfObjects < 2) && (pObject->ItemData.Generic.bStatus[0] < USABLE) ) { return( TRUE ); } @@ -5871,10 +5863,10 @@ void WaterDamage( SOLDIERTYPE *pSoldier ) bDamage = (INT8) (10 - uiRoll); // but don't let anything drop lower than 1% - pSoldier->inv[bLoop].bStatus[0] -= bDamage; - if (pSoldier->inv[bLoop].bStatus[0] < 1) + pSoldier->inv[bLoop].ItemData.Generic.bStatus[0] -= bDamage; + if (pSoldier->inv[bLoop].ItemData.Generic.bStatus[0] < 1) { - pSoldier->inv[bLoop].bStatus[0] = 1; + pSoldier->inv[bLoop].ItemData.Generic.bStatus[0] = 1; } } } @@ -6129,7 +6121,7 @@ UINT8 ConvertObjectTypeMoneyValueToProfileMoneyValue( UINT32 uiMoneyAmount ) BOOLEAN ItemIsCool( OBJECTTYPE * pObj ) { - if (pObj->bStatus[0] < 60) + if (pObj->ItemData.Generic.bStatus[0] < 60) { return( FALSE ); } @@ -6308,7 +6300,7 @@ INT16 BonusOnOff( INT16 bonus, INT8 status ) // Snap: a fast aimbonus check for AI BOOLEAN IsScoped( const OBJECTTYPE * pObj ) { - if ( Item[pObj->usItem].aimbonus > 0 || Item[pObj->usGunAmmoItem].aimbonus > 0 ) + if ( Item[pObj->usItem].aimbonus > 0 || Item[pObj->ItemData.Gun.usGunAmmoItem].aimbonus > 0 ) return TRUE; for (int i = 0; i < MAX_ATTACHMENTS; i++) @@ -6337,8 +6329,8 @@ INT16 GetAimBonus( OBJECTTYPE * pObj, INT32 iRange, UINT8 ubAimTime ) { INT16 bns; - bns = BonusReduceMore( GetItemAimBonus( &Item[pObj->usItem], iRange, ubAimTime ), pObj->bStatus[0] ); - bns += GetItemAimBonus( &Item[pObj->usGunAmmoItem], iRange, ubAimTime ); + bns = BonusReduceMore( GetItemAimBonus( &Item[pObj->usItem], iRange, ubAimTime ), pObj->ItemData.Generic.bStatus[0] ); + bns += GetItemAimBonus( &Item[pObj->ItemData.Gun.usGunAmmoItem], iRange, ubAimTime ); for (int i = 0; i < MAX_ATTACHMENTS; i++) { @@ -6419,14 +6411,14 @@ INT16 GetRangeBonus( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = BonusReduce( Item[pObj->usItem].rangebonus, pObj->bStatus[0] ); + bns = BonusReduce( Item[pObj->usItem].rangebonus, pObj->ItemData.Generic.bStatus[0] ); - if ( pObj->ubGunShotsLeft > 0 ) - bns += Item[pObj->usGunAmmoItem].rangebonus; + if ( pObj->ItemData.Gun.ubGunShotsLeft > 0 ) + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].rangebonus; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { - if ( !Item[pObj->usAttachItem[bLoop]].duckbill || ( Item[pObj->usAttachItem[bLoop]].duckbill && pObj->ubGunAmmoType == AMMO_BUCKSHOT )) + if ( !Item[pObj->usAttachItem[bLoop]].duckbill || ( Item[pObj->usAttachItem[bLoop]].duckbill && pObj->ItemData.Gun.ubGunAmmoType == AMMO_BUCKSHOT )) bns += BonusReduce( Item[pObj->usAttachItem[bLoop]].rangebonus, pObj->bAttachStatus[bLoop] ); } @@ -6467,8 +6459,8 @@ INT16 GetToHitBonus( OBJECTTYPE * pObj, INT32 iRange, UINT8 bLightLevel, BOOLEAN if ( fProneStance ) bns += Item[pObj->usItem].bipod; - bns += BonusReduceMore( LaserBonus( &Item[pObj->usItem], iRange, bLightLevel), pObj->bStatus[0] ); - bns += Item[pObj->usGunAmmoItem].tohitbonus; + bns += BonusReduceMore( LaserBonus( &Item[pObj->usItem], iRange, bLightLevel), pObj->ItemData.Generic.bStatus[0] ); + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].tohitbonus; for (int i = 0; i < MAX_ATTACHMENTS; i++) { @@ -6491,8 +6483,8 @@ INT16 GetBurstToHitBonus( OBJECTTYPE * pObj, BOOLEAN fProneStance ) if ( fProneStance ) bns += Item[pObj->usItem].bipod; - bns += BonusReduceMore( Item[pObj->usItem].bursttohitbonus, pObj->bStatus[0] ); - bns += Item[pObj->usGunAmmoItem].bursttohitbonus ; + bns += BonusReduceMore( Item[pObj->usItem].bursttohitbonus, pObj->ItemData.Generic.bStatus[0] ); + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].bursttohitbonus ; for (int i = 0; i < MAX_ATTACHMENTS; i++) { @@ -6511,10 +6503,10 @@ INT16 GetDamageBonus( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = BonusReduce( Item[pObj->usItem].damagebonus, pObj->bStatus[0] ); + bns = BonusReduce( Item[pObj->usItem].damagebonus, pObj->ItemData.Generic.bStatus[0] ); - if ( pObj->ubGunShotsLeft > 0 ) - bns += Item[pObj->usGunAmmoItem].damagebonus ; + if ( pObj->ItemData.Gun.ubGunShotsLeft > 0 ) + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].damagebonus ; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -6531,8 +6523,8 @@ INT16 GetMeleeDamageBonus( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = BonusReduce( Item[pObj->usItem].meleedamagebonus, pObj->bStatus[0]); - bns += Item[pObj->usGunAmmoItem].meleedamagebonus ; + bns = BonusReduce( Item[pObj->usItem].meleedamagebonus, pObj->ItemData.Generic.bStatus[0]); + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].meleedamagebonus ; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -6548,8 +6540,8 @@ INT16 GetPercentAPReduction( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = BonusReduceMore( Item[pObj->usItem].percentapreduction, pObj->bStatus[0] ); - bns += Item[pObj->usGunAmmoItem].percentapreduction; + bns = BonusReduceMore( Item[pObj->usItem].percentapreduction, pObj->ItemData.Generic.bStatus[0] ); + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].percentapreduction; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -6565,8 +6557,8 @@ INT16 GetMagSizeBonus( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = BonusOnOff( Item[pObj->usItem].magsizebonus, pObj->bStatus[0] ); -// bns = bns + Item[pObj->usGunAmmoItem].magsizebonus ; + bns = BonusOnOff( Item[pObj->usItem].magsizebonus, pObj->ItemData.Generic.bStatus[0] ); +// bns = bns + Item[pObj->ItemData.Gun.usGunAmmoItem].magsizebonus ; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -6580,8 +6572,8 @@ INT16 GetBurstSizeBonus( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = BonusOnOff( Item[pObj->usItem].burstsizebonus, pObj->bStatus[0] ); - bns += Item[pObj->usGunAmmoItem].burstsizebonus ; + bns = BonusOnOff( Item[pObj->usItem].burstsizebonus, pObj->ItemData.Generic.bStatus[0] ); + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].burstsizebonus ; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -6596,16 +6588,16 @@ INT16 GetRateOfFireBonus( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - if( (MAXITEMS <= pObj->usItem) || (MAXITEMS <= pObj->usGunAmmoItem) ) + if( (MAXITEMS <= pObj->usItem) || (MAXITEMS <= pObj->ItemData.Gun.usGunAmmoItem) ) { - DebugMsg(TOPIC_JA2, DBG_LEVEL_1, String("GetRateOfFireBonus would crash: pObj->usItem=%d or pObj->usGunAmmoItem=%d ist higher than max %d", pObj->usItem, pObj->usGunAmmoItem, MAXITEMS )); - ScreenMsg( MSG_FONT_RED, MSG_DEBUG, L"GetRateOfFireBonus would crash: pObj->usItem=%d or pObj->usGunAmmoItem=%d ist higher than max %d", pObj->usItem, pObj->usGunAmmoItem, MAXITEMS ); + DebugMsg(TOPIC_JA2, DBG_LEVEL_1, String("GetRateOfFireBonus would crash: pObj->usItem=%d or pObj->ItemData.Gun.usGunAmmoItem=%d ist higher than max %d", pObj->usItem, pObj->ItemData.Gun.usGunAmmoItem, MAXITEMS )); + ScreenMsg( MSG_FONT_RED, MSG_DEBUG, L"GetRateOfFireBonus would crash: pObj->usItem=%d or pObj->ItemData.Gun.usGunAmmoItem=%d ist higher than max %d", pObj->usItem, pObj->ItemData.Gun.usGunAmmoItem, MAXITEMS ); AssertMsg( 0, "GetRateOfFireBonus would crash" ); return 0; /* cannot calculate Bonus, this only happens sometimes in FULLSCREEN */ } - bns = BonusReduceMore( Item[pObj->usItem].rateoffirebonus, pObj->bStatus[0] ); - bns += Item[pObj->usGunAmmoItem].rateoffirebonus ; + bns = BonusReduceMore( Item[pObj->usItem].rateoffirebonus, pObj->ItemData.Generic.bStatus[0] ); + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].rateoffirebonus ; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -6624,9 +6616,9 @@ INT16 GetAutoToHitBonus( OBJECTTYPE * pObj, BOOLEAN fProneStance ) bns += Item[pObj->usItem].bipod; - bns += BonusReduceMore( Item[pObj->usItem].autofiretohitbonus, pObj->bStatus[0] ); + bns += BonusReduceMore( Item[pObj->usItem].autofiretohitbonus, pObj->ItemData.Generic.bStatus[0] ); - bns += Item[pObj->usGunAmmoItem].autofiretohitbonus ; + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].autofiretohitbonus ; for (int i = 0; i < MAX_ATTACHMENTS; i++) { @@ -6644,8 +6636,8 @@ INT16 GetPercentReadyTimeAPReduction( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = BonusReduceMore( Item[pObj->usItem].percentreadytimeapreduction, pObj->bStatus[0] ); - bns += Item[pObj->usGunAmmoItem].percentreadytimeapreduction; + bns = BonusReduceMore( Item[pObj->usItem].percentreadytimeapreduction, pObj->ItemData.Generic.bStatus[0] ); + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].percentreadytimeapreduction; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -6660,8 +6652,8 @@ INT16 GetPercentAutofireAPReduction( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = BonusReduceMore( Item[pObj->usItem].percentautofireapreduction, pObj->bStatus[0] ); - bns += Item[pObj->usGunAmmoItem].percentautofireapreduction; + bns = BonusReduceMore( Item[pObj->usItem].percentautofireapreduction, pObj->ItemData.Generic.bStatus[0] ); + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].percentautofireapreduction; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -6676,8 +6668,8 @@ INT16 GetPercentReloadTimeAPReduction( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = BonusReduceMore( Item[pObj->usItem].percentreloadtimeapreduction, pObj->bStatus[0] ); - bns += Item[pObj->usGunAmmoItem].percentreloadtimeapreduction; + bns = BonusReduceMore( Item[pObj->usItem].percentreloadtimeapreduction, pObj->ItemData.Generic.bStatus[0] ); + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].percentreloadtimeapreduction; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -6691,8 +6683,8 @@ INT16 GetPercentBurstFireAPReduction( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = BonusReduceMore( Item[pObj->usItem].percentburstfireapreduction, pObj->bStatus[0] ); - bns += Item[pObj->usGunAmmoItem].percentburstfireapreduction; + bns = BonusReduceMore( Item[pObj->usItem].percentburstfireapreduction, pObj->ItemData.Generic.bStatus[0] ); + bns += Item[pObj->ItemData.Gun.usGunAmmoItem].percentburstfireapreduction; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -6724,7 +6716,7 @@ INT16 GetVisionRangeBonus( SOLDIERTYPE * pSoldier ) if (!IsWeapon(usItem) || (IsWeapon(usItem) && WeaponReady(pSoldier) ) ) { - bns += BonusReduceMore( pItem->visionrangebonus, pObj->bStatus[0] ); + bns += BonusReduceMore( pItem->visionrangebonus, pObj->ItemData.Generic.bStatus[0] ); } } @@ -6781,7 +6773,7 @@ INT16 GetNightVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel ) { bns += BonusReduceMore( NightBonusScale( pItem->nightvisionrangebonus, bLightLevel ), - pObj->bStatus[0] ); + pObj->ItemData.Generic.bStatus[0] ); } } @@ -6826,7 +6818,7 @@ INT16 GetCaveVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel ) { bns += BonusReduceMore( NightBonusScale( pItem->cavevisionrangebonus, bLightLevel ), - pObj->bStatus[0] ); + pObj->ItemData.Generic.bStatus[0] ); } } @@ -6873,7 +6865,7 @@ INT16 GetDayVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel ) { bns += BonusReduceMore( idiv( pItem->dayvisionrangebonus * (NORMAL_LIGHTLEVEL_NIGHT - bLightLevel), NORMAL_LIGHTLEVEL_NIGHT ), - pObj->bStatus[0] ); + pObj->ItemData.Generic.bStatus[0] ); } } @@ -6920,7 +6912,7 @@ INT16 GetBrightLightVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel { bns += BonusReduceMore( idiv( pItem->brightlightvisionrangebonus * (NORMAL_LIGHTLEVEL_DAY - bLightLevel), NORMAL_LIGHTLEVEL_DAY ), - pObj->bStatus[0] ); + pObj->ItemData.Generic.bStatus[0] ); } } @@ -7077,7 +7069,7 @@ INT16 GetHearingRangeBonus( SOLDIERTYPE * pSoldier ) continue; } - bns += BonusReduceMore( Item[pSoldier->inv[i].usItem].hearingrangebonus, pSoldier->inv[i].bStatus[0] ); + bns += BonusReduceMore( Item[pSoldier->inv[i].usItem].hearingrangebonus, pSoldier->inv[i].ItemData.Generic.bStatus[0] ); /*for (UINT8 i=0;iinv[bLoop].usAttachItem[i] != NONE && Item[pSoldier->inv[bLoop].usAttachItem[i]].hearingrangebonus > 0 ) @@ -7092,7 +7084,7 @@ BOOLEAN IsDuckbill( OBJECTTYPE * pObj ) { INT8 bLoop; - if (Item[pObj->usItem].duckbill || Item[pObj->usGunAmmoItem].duckbill ) + if (Item[pObj->usItem].duckbill || Item[pObj->ItemData.Gun.usGunAmmoItem].duckbill ) return TRUE; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) @@ -7108,8 +7100,8 @@ BOOLEAN IsDuckbill( OBJECTTYPE * pObj ) UINT16 GetPercentNoiseVolume( OBJECTTYPE * pObj ) { - UINT16 mod = 100 - BonusReduce( Item[pObj->usItem].percentnoisereduction, pObj->bStatus[0] ); - mod = mod * ( 100 - Item[pObj->usGunAmmoItem].percentnoisereduction ) / 100; + UINT16 mod = 100 - BonusReduce( Item[pObj->usItem].percentnoisereduction, pObj->ItemData.Generic.bStatus[0] ); + mod = mod * ( 100 - Item[pObj->ItemData.Gun.usGunAmmoItem].percentnoisereduction ) / 100; for (int i = 0; i < MAX_ATTACHMENTS; i++) { @@ -7174,13 +7166,13 @@ BOOLEAN IsFlashSuppressor( OBJECTTYPE * pObj, SOLDIERTYPE * pSoldier ) INT8 bLoop; //Madd: tracers automatically negate any muzzle flash suppression due to inherent lighting effects - if (Item[pObj->usItem].usItemClass == IC_GUN && AmmoTypes[pObj->ubGunAmmoType].tracerEffect && pSoldier->bDoBurst ) + if (Item[pObj->usItem].usItemClass == IC_GUN && AmmoTypes[pObj->ItemData.Gun.ubGunAmmoType].tracerEffect && pSoldier->bDoBurst ) return FALSE; if (Item[pObj->usItem].hidemuzzleflash ) return TRUE; - if ( Item[pObj->usGunAmmoItem].hidemuzzleflash ) + if ( Item[pObj->ItemData.Gun.usGunAmmoItem].hidemuzzleflash ) return TRUE; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) @@ -7198,7 +7190,7 @@ INT16 GetFlashSuppressorStatus( OBJECTTYPE * pObj ) INT8 bLoop; INT16 p=100; if (Item[pObj->usItem].hidemuzzleflash ) - p=pObj->bStatus[0]; + p=pObj->ItemData.Generic.bStatus[0]; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -7249,7 +7241,7 @@ INT8 GetGrenadeLauncherStatus( OBJECTTYPE * pObj ) INT8 bLoop; if (Item[pObj->usItem].grenadelauncher ) - return pObj->bStatus[0]; + return pObj->ItemData.Generic.bStatus[0]; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -7313,7 +7305,7 @@ INT16 GetBulletSpeedBonus( OBJECTTYPE * pObj ) INT16 bns=0; bns = Item[pObj->usItem].bulletspeedbonus ; - bns = bns + Item[pObj->usGunAmmoItem].bulletspeedbonus ; + bns = bns + Item[pObj->ItemData.Gun.usGunAmmoItem].bulletspeedbonus ; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -7377,7 +7369,7 @@ INT8 FindUsableCrowbar( SOLDIERTYPE * pSoldier ) for (bLoop = 0; bLoop < NUM_INV_SLOTS; bLoop++) { - if ( Item[pSoldier->inv[bLoop].usItem].crowbar && pSoldier->inv[bLoop].bStatus[0] >= USABLE ) + if ( Item[pSoldier->inv[bLoop].usItem].crowbar && pSoldier->inv[bLoop].ItemData.Generic.bStatus[0] >= USABLE ) { return( bLoop ); } @@ -7567,7 +7559,7 @@ INT16 GetCamoBonus( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = (INT16) (Item[pObj->usItem].camobonus);// * (WEAPON_STATUS_MOD(pObj->bStatus[0]) / 100)) ; + bns = (INT16) (Item[pObj->usItem].camobonus);// * (WEAPON_STATUS_MOD(pObj->ItemData.Generic.bStatus[0]) / 100)) ; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -7581,7 +7573,7 @@ INT16 GetUrbanCamoBonus( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = (INT16) (Item[pObj->usItem].urbanCamobonus);// * (WEAPON_STATUS_MOD(pObj->bStatus[0]) / 100)) ; + bns = (INT16) (Item[pObj->usItem].urbanCamobonus);// * (WEAPON_STATUS_MOD(pObj->ItemData.Generic.bStatus[0]) / 100)) ; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -7595,7 +7587,7 @@ INT16 GetDesertCamoBonus( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = (INT16) (Item[pObj->usItem].desertCamobonus);// * (WEAPON_STATUS_MOD(pObj->bStatus[0]) / 100)) ; + bns = (INT16) (Item[pObj->usItem].desertCamobonus);// * (WEAPON_STATUS_MOD(pObj->ItemData.Generic.bStatus[0]) / 100)) ; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -7609,7 +7601,7 @@ INT16 GetSnowCamoBonus( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = (INT16) (Item[pObj->usItem].snowCamobonus);// * (WEAPON_STATUS_MOD(pObj->bStatus[0]) / 100)) ; + bns = (INT16) (Item[pObj->usItem].snowCamobonus);// * (WEAPON_STATUS_MOD(pObj->ItemData.Generic.bStatus[0]) / 100)) ; for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { @@ -7762,7 +7754,7 @@ INT16 GetMinRangeForAimBonus( OBJECTTYPE * pObj ) INT16 bns; bns = Item[pObj->usItem].minrangeforaimbonus; - //bns += Item[pObj->usGunAmmoItem].minrangeforaimbonus; + //bns += Item[pObj->ItemData.Gun.usGunAmmoItem].minrangeforaimbonus; for (int i = 0; i < MAX_ATTACHMENTS; i++) { @@ -7805,7 +7797,7 @@ INT16 GetStealthBonus( OBJECTTYPE * pObj ) INT8 bLoop; INT16 bns=0; - bns = (INT16) BonusReduce(Item[pObj->usItem].stealthbonus,pObj->bStatus[0]); + bns = (INT16) BonusReduce(Item[pObj->usItem].stealthbonus,pObj->ItemData.Generic.bStatus[0]); for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) { diff --git a/Tactical/Items.h b/Tactical/Items.h index 15dcaf20..7c7f7f2b 100644 --- a/Tactical/Items.h +++ b/Tactical/Items.h @@ -60,6 +60,7 @@ extern UINT16 DefaultMagazine( UINT16 usItem ); UINT16 RandomMagazine( UINT16 usItem, UINT8 ubPercentStandard ); UINT16 RandomMagazine( OBJECTTYPE * pGun, UINT8 ubPercentStandard ); extern BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo ); +extern BOOLEAN UnloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun); UINT8 ItemSlotLimit( UINT16 usItem, INT8 bSlot ); diff --git a/Tactical/Keys.cpp b/Tactical/Keys.cpp index 1a12c3ce..c37436c5 100644 --- a/Tactical/Keys.cpp +++ b/Tactical/Keys.cpp @@ -199,7 +199,7 @@ BOOLEAN KeyExistsInInventory( SOLDIERTYPE *pSoldier, UINT8 ubKeyID ) { if (Item[pSoldier->inv[ubLoop].usItem].usItemClass == IC_KEY) { - if ( (pSoldier->inv[ubLoop].ubKeyID == ubKeyID) || (ubKeyID == ANYKEY) ) + if ( (pSoldier->inv[ubLoop].ItemData.Key.ubKeyID == ubKeyID) || (ubKeyID == ANYKEY) ) { // there's the key we want! return( TRUE ); diff --git a/Tactical/LOS.cpp b/Tactical/LOS.cpp index be5f1579..f30c8a9f 100644 --- a/Tactical/LOS.cpp +++ b/Tactical/LOS.cpp @@ -1998,7 +1998,7 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend } else { - ubAmmoType = pFirer->inv[pFirer->ubAttackingHand].ubGunAmmoType; + ubAmmoType = pFirer->inv[pFirer->ubAttackingHand].ItemData.Gun.ubGunAmmoType; } // at least partly compensate for "near miss" increases for this guy, after all, the bullet @@ -2119,12 +2119,12 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend // lucky bastard was facing away! } // else if ( ( (pTarget->inv[HEAD1POS].usItem == NIGHTGOGGLES) || (pTarget->inv[HEAD1POS].usItem == SUNGOGGLES) || (pTarget->inv[HEAD1POS].usItem == GASMASK) ) && ( PreRandom( 100 ) < (UINT32) (pTarget->inv[HEAD1POS].bStatus[ 0 ]) ) ) - else if ( ( (pTarget->inv[HEAD1POS].usItem != NONE) ) && ( PreRandom( 100 ) < (UINT32) (pTarget->inv[HEAD1POS].bStatus[ 0 ]) ) ) + else if ( ( (pTarget->inv[HEAD1POS].usItem != NONE) ) && ( PreRandom( 100 ) < (UINT32) (pTarget->inv[HEAD1POS].ItemData.Generic.bStatus[ 0 ]) ) ) { // lucky bastard was wearing protective stuff bHeadSlot = HEAD1POS; } - else if ( ( (pTarget->inv[HEAD2POS].usItem != NONE) ) && ( PreRandom( 100 ) < (UINT32) (pTarget->inv[HEAD2POS].bStatus[ 0 ]) ) ) + else if ( ( (pTarget->inv[HEAD2POS].usItem != NONE) ) && ( PreRandom( 100 ) < (UINT32) (pTarget->inv[HEAD2POS].ItemData.Generic.bStatus[ 0 ]) ) ) { // lucky bastard was wearing protective stuff bHeadSlot = HEAD2POS; @@ -2204,10 +2204,10 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend { if (bHeadSlot != NO_SLOT) { - pTarget->inv[ bHeadSlot ].bStatus[ 0 ] -= (INT8) ( (iImpact / 2) + Random( (iImpact / 2) ) ); - if ( pTarget->inv[ bHeadSlot ].bStatus[ 0 ] <= USABLE ) + pTarget->inv[ bHeadSlot ].ItemData.Generic.bStatus[ 0 ] -= (INT8) ( (iImpact / 2) + Random( (iImpact / 2) ) ); + if ( pTarget->inv[ bHeadSlot ].ItemData.Generic.bStatus[ 0 ] <= USABLE ) { - if ( pTarget->inv[ bHeadSlot ].bStatus[ 0 ] <= 0 ) + if ( pTarget->inv[ bHeadSlot ].ItemData.Generic.bStatus[ 0 ] <= 0 ) { DeleteObj( &(pTarget->inv[ bHeadSlot ]) ); DirtyMercPanelInterface( pTarget, DIRTYLEVEL2 ); @@ -2222,11 +2222,11 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend bHeadSlot = HEAD1POS + (INT8) Random( 2 ); if ( pTarget->inv[ bHeadSlot ].usItem != NOTHING ) { - pTarget->inv[ bHeadSlot ].bStatus[ 0 ] -= (INT8) ( Random( iImpact / 2 ) ); - if ( pTarget->inv[ bHeadSlot ].bStatus[ 0 ] < 0 ) + pTarget->inv[ bHeadSlot ].ItemData.Generic.bStatus[ 0 ] -= (INT8) ( Random( iImpact / 2 ) ); + if ( pTarget->inv[ bHeadSlot ].ItemData.Generic.bStatus[ 0 ] < 0 ) { // just break it... - pTarget->inv[ bHeadSlot ].bStatus[ 0 ] = 1; + pTarget->inv[ bHeadSlot ].ItemData.Generic.bStatus[ 0 ] = 1; } } } @@ -2465,7 +2465,7 @@ INT32 HandleBulletStructureInteraction( BULLET * pBullet, STRUCTURE * pStructure //else if ( pBullet->usFlags & BULLET_FLAG_SMALL_MISSILE ) //{ // stops if using HE ammo - else if ( AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ubGunAmmoType].highExplosive && !AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ubGunAmmoType].antiTank ) + else if ( AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].highExplosive && !AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].antiTank ) { *pfHit = TRUE; return( 0 ); @@ -2481,7 +2481,7 @@ INT32 HandleBulletStructureInteraction( BULLET * pBullet, STRUCTURE * pStructure pDoor = FindDoorInfoAtGridNo( pBullet->sGridNo ); // Does it have a lock? - INT16 lockBustingPower = AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ubGunAmmoType].lockBustingPower; + INT16 lockBustingPower = AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].lockBustingPower; // WANNE: bugfix: No door returned, so the game crashes! if (pDoor) @@ -2545,7 +2545,7 @@ INT32 HandleBulletStructureInteraction( BULLET * pBullet, STRUCTURE * pStructure iImpactReduction = gubMaterialArmour[ pStructure->pDBStructureRef->pDBStructure->ubArmour ]; iImpactReduction = StructureResistanceIncreasedByRange( iImpactReduction, pBullet->iRange, pBullet->iLoop ); - iImpactReduction = (INT32) (iImpactReduction * AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ubGunAmmoType].structureImpactReductionMultiplier / max(1,AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ubGunAmmoType].structureImpactReductionDivisor)); + iImpactReduction = (INT32) (iImpactReduction * AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].structureImpactReductionMultiplier / max(1,AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].structureImpactReductionDivisor)); //switch (pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ubGunAmmoType) //{ @@ -2599,7 +2599,7 @@ INT32 CTGTHandleBulletStructureInteraction( BULLET * pBullet, STRUCTURE * pStruc //else if ( pBullet->usFlags & BULLET_FLAG_SMALL_MISSILE ) //{ // stops if using HE ammo - else if ( AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ubGunAmmoType].highExplosive && !AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ubGunAmmoType].antiTank ) + else if ( AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].highExplosive && !AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].antiTank ) { return( pBullet->iImpact ); } @@ -2626,7 +2626,7 @@ INT32 CTGTHandleBulletStructureInteraction( BULLET * pBullet, STRUCTURE * pStruc iImpactReduction = gubMaterialArmour[ pStructure->pDBStructureRef->pDBStructure->ubArmour ] * pStructure->pDBStructureRef->pDBStructure->ubDensity / 100; iImpactReduction = StructureResistanceIncreasedByRange( iImpactReduction, pBullet->iRange, pBullet->iLoop ); - iImpactReduction = (INT32)(iImpactReduction * AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ubGunAmmoType].structureImpactReductionMultiplier / max(1,AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ubGunAmmoType].structureImpactReductionDivisor)); + iImpactReduction = (INT32)(iImpactReduction * AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].structureImpactReductionMultiplier / max(1,AmmoTypes[pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].structureImpactReductionDivisor)); //switch (pBullet->pFirer->inv[ pBullet->pFirer->ubAttackingHand ].ubGunAmmoType) //{ @@ -3608,7 +3608,7 @@ INT8 FireBulletGivenTarget( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, FLOA usBulletFlags |= BULLET_FLAG_FLAME; ubSpreadIndex = 2; } - else if ( AmmoTypes[ pFirer->inv[pFirer->ubAttackingHand].ubGunAmmoType ].tracerEffect && (pFirer->bDoBurst || gGameSettings.fOptions[ TOPTION_TRACERS_FOR_SINGLE_FIRE ]) ) + else if ( AmmoTypes[ pFirer->inv[pFirer->ubAttackingHand].ItemData.Gun.ubGunAmmoType ].tracerEffect && (pFirer->bDoBurst || gGameSettings.fOptions[ TOPTION_TRACERS_FOR_SINGLE_FIRE ]) ) { //usBulletFlags |= BULLET_FLAG_TRACER; fTracer = TRUE; @@ -3622,7 +3622,7 @@ INT8 FireBulletGivenTarget( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, FLOA // shotgun pellets fire 9 bullets doing 1/4 damage each if (!fFake) { - ubShots = AmmoTypes[pFirer->inv[pFirer->ubAttackingHand].ubGunAmmoType].numberOfBullets; + ubShots = AmmoTypes[pFirer->inv[pFirer->ubAttackingHand].ItemData.Gun.ubGunAmmoType].numberOfBullets; // but you can't really aim the damn things very well! if (sHitBy > 0) { @@ -3640,7 +3640,7 @@ INT8 FireBulletGivenTarget( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, FLOA } // ubImpact = AMMO_DAMAGE_ADJUSTMENT_BUCKSHOT( ubImpact ); - ubImpact = (UINT8) (ubImpact * AmmoTypes[pFirer->inv[pFirer->ubAttackingHand].ubGunAmmoType].multipleBulletDamageMultiplier / max(1,AmmoTypes[pFirer->inv[pFirer->ubAttackingHand].ubGunAmmoType].multipleBulletDamageDivisor) ); + ubImpact = (UINT8) (ubImpact * AmmoTypes[pFirer->inv[pFirer->ubAttackingHand].ItemData.Gun.ubGunAmmoType].multipleBulletDamageMultiplier / max(1,AmmoTypes[pFirer->inv[pFirer->ubAttackingHand].ItemData.Gun.ubGunAmmoType].multipleBulletDamageDivisor) ); } } @@ -3727,7 +3727,7 @@ INT8 FireBulletGivenTarget( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, FLOA if ( pBullet->usFlags & BULLET_FLAG_KNIFE ) { - pBullet->ubItemStatus = pFirer->inv[pFirer->ubAttackingHand].bStatus[0]; + pBullet->ubItemStatus = pFirer->inv[pFirer->ubAttackingHand].ItemData.Generic.bStatus[0]; } // apply increments for first move @@ -3787,7 +3787,7 @@ INT8 ChanceToGetThrough( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, FLOAT d // if shotgun, shotgun would have to be in main hand if ( pFirer->inv[ HANDPOS ].usItem == pFirer->usAttackingWeapon ) { - if ( AmmoTypes[pFirer->inv[ HANDPOS ].ubGunAmmoType].numberOfBullets > 1 ) + if ( AmmoTypes[pFirer->inv[ HANDPOS ].ItemData.Gun.ubGunAmmoType].numberOfBullets > 1 ) { fBuckShot = TRUE; } diff --git a/Tactical/Merc Hiring.cpp b/Tactical/Merc Hiring.cpp index 408169c0..dab6dfe2 100644 --- a/Tactical/Merc Hiring.cpp +++ b/Tactical/Merc Hiring.cpp @@ -138,7 +138,7 @@ INT8 HireMerc( MERC_HIRE_STRUCT *pHireMerc) memset( &Object, 0, sizeof( OBJECTTYPE ) ); Object.usItem = LETTER; Object.ubNumberOfObjects = 1; - Object.bStatus[0] = 100; + Object.ItemData.Generic.bStatus[0] = 100; // Give it fReturn = AutoPlaceObject( MercPtrs[iNewIndex], &Object, FALSE ); Assert( fReturn ); diff --git a/Tactical/Militia Control.cpp b/Tactical/Militia Control.cpp index dd53323e..a67750d7 100644 --- a/Tactical/Militia Control.cpp +++ b/Tactical/Militia Control.cpp @@ -222,6 +222,11 @@ void PrepareMilitiaForTactical( BOOLEAN fPrepareAll) if ( gWorldSectorX ==0 && gWorldSectorY == 0 ) return; + for (int i=0; ibActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE); + } + pSector = &SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY ) ]; ubGreen = pSector->ubNumberOfCivsAtLevel[ GREEN_MILITIA ]; ubRegs = pSector->ubNumberOfCivsAtLevel[ REGULAR_MILITIA ]; @@ -248,8 +253,8 @@ void PrepareMilitiaForTactical( BOOLEAN fPrepareAll) ubElites -= gpAttackDirs[ x ][2]; } } - else - { + //else + //{ #endif AddSoldierInitListMilitiaOnEdge( gpAttackDirs[ x ][ 3 ], gpAttackDirs[ x ][0], gpAttackDirs[ x ][1], gpAttackDirs[ x ][2] ); } @@ -269,6 +274,11 @@ void PrepareMilitiaForTactical( BOOLEAN fPrepareAll) //// MercPtrs[ i ]->bAttitude = AGGRESSIVE; // } // } + + for (int i=0; ibActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE); + } } void HandleMilitiaPromotions( void ) diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp index 06078969..58a64983 100644 --- a/Tactical/Points.cpp +++ b/Tactical/Points.cpp @@ -1626,7 +1626,7 @@ BOOLEAN EnoughAmmo( SOLDIERTYPE *pSoldier, BOOLEAN fDisplay, INT8 bInvPos ) } else if (Item[ pSoldier->inv[ bInvPos ].usItem ].usItemClass == IC_GUN) { - if ( pSoldier->inv[ bInvPos ].ubGunShotsLeft == 0 ) + if ( pSoldier->inv[ bInvPos ].ItemData.Gun.ubGunShotsLeft == 0 ) { if ( fDisplay ) { @@ -1638,7 +1638,7 @@ BOOLEAN EnoughAmmo( SOLDIERTYPE *pSoldier, BOOLEAN fDisplay, INT8 bInvPos ) // manual recharge if( pSoldier->bTeam == OUR_TEAM ) { - if ( !( pSoldier->inv[ bInvPos ].ubGunState & GS_CARTRIDGE_IN_CHAMBER ) ) + if ( !( pSoldier->inv[ bInvPos ].ItemData.Gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER ) ) { return( FALSE ); } @@ -1677,11 +1677,11 @@ void DeductAmmo( SOLDIERTYPE *pSoldier, INT8 bInvPos ) if ( pSoldier->usAttackingWeapon == pObj->usItem) { // OK, let's see, don't overrun... - if ( pObj->ubGunShotsLeft != 0 ) + if ( pObj->ItemData.Gun.ubGunShotsLeft != 0 ) { - pObj->ubGunShotsLeft--; + pObj->ItemData.Gun.ubGunShotsLeft--; //Pulmu: Update weight after firing gun to account for bullets fired - if( gGameExternalOptions.fAmmoDynamicWeight == TRUE && pObj->ubGunShotsLeft > 0) + if( gGameExternalOptions.fAmmoDynamicWeight == TRUE && pObj->ItemData.Gun.ubGunShotsLeft > 0) { pSoldier->inv[HANDPOS].ubWeight = CalculateObjectWeight( &(pSoldier->inv[HANDPOS])); } @@ -1823,7 +1823,7 @@ INT8 GetAPsToAutoReload( SOLDIERTYPE * pSoldier ) pObj = &(pSoldier->inv[HANDPOS]); // manual recharge - if (pObj->ubGunShotsLeft && !(pObj->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) + if (pObj->ItemData.Gun.ubGunShotsLeft && !(pObj->ItemData.Gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) { return Weapon[Item[(pObj)->usItem].ubClassIndex].APsToReloadManually; } diff --git a/Tactical/Rotting Corpses.cpp b/Tactical/Rotting Corpses.cpp index e5fcfdd2..86c013ed 100644 --- a/Tactical/Rotting Corpses.cpp +++ b/Tactical/Rotting Corpses.cpp @@ -939,8 +939,8 @@ BOOLEAN TurnSoldierIntoCorpse( SOLDIERTYPE *pSoldier, BOOLEAN fRemoveMerc, BOOLE if ( Item[pObj->usItem].damageable && Item[pObj->usItem].usItemClass != IC_THROWING_KNIFE ) // Madd: drop crappier items from enemies on higher difficulty levels - note the quick fix for throwing knives { - pObj->bStatus[0] -= (gGameOptions.ubDifficultyLevel - 1) * Random(20); - pObj->bStatus[0] = min(max(pObj->bStatus[0],1),100); // never below 1% or above 100% + pObj->ItemData.Generic.bStatus[0] -= (gGameOptions.ubDifficultyLevel - 1) * Random(20); + pObj->ItemData.Generic.bStatus[0] = min(max(pObj->ItemData.Generic.bStatus[0],1),100); // never below 1% or above 100% } } diff --git a/Tactical/ShopKeeper Interface.cpp b/Tactical/ShopKeeper Interface.cpp index 573133c3..585ccff9 100644 --- a/Tactical/ShopKeeper Interface.cpp +++ b/Tactical/ShopKeeper Interface.cpp @@ -2287,7 +2287,7 @@ void SelectPlayersOfferSlotsRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason { //Since money is always evaluated PlayersOfferArea[ ubSelectedInvSlot ].uiFlags |= ARMS_INV_PLAYERS_ITEM_HAS_VALUE; - PlayersOfferArea[ ubSelectedInvSlot ].uiItemPrice = PlayersOfferArea[ ubSelectedInvSlot ].ItemObject.bMoneyStatus; + PlayersOfferArea[ ubSelectedInvSlot ].uiItemPrice = PlayersOfferArea[ ubSelectedInvSlot ].ItemObject.ItemData.Money.bMoneyStatus; } } else // slot is empty @@ -2759,7 +2759,7 @@ UINT32 DisplayInvSlot( UINT8 ubSlotNum, UINT16 usItemIndex, UINT16 usPosX, UINT1 } // Display 'JAMMED' if it's jammed - if ( pItemObject->bGunAmmoStatus < 0 ) + if ( pItemObject->ItemData.Gun.bGunAmmoStatus < 0 ) { swprintf( zTemp, TacticalStr[ JAMMED_ITEM_STR ] ); VarFindFontCenterCoordinates( usPosX, usPosY, SKI_INV_SLOT_WIDTH, SKI_INV_HEIGHT, TINYFONT1, &sCenX, &sCenY, zTemp ); @@ -3002,7 +3002,7 @@ BOOLEAN RepairIsDone(UINT16 usItemIndex, UINT8 ubElement) if ( CanDealerRepairItem( gbSelectedArmsDealerID, RepairItem.ItemObject.usItem ) ) { // make its condition 100% - RepairItem.ItemObject.bStatus[ 0 ] = 100; + RepairItem.ItemObject.ItemData.Generic.bStatus[ 0 ] = 100; } // max condition of all permanent attachments on it @@ -3096,25 +3096,25 @@ UINT32 CalcShopKeeperItemPrice( BOOLEAN fDealerSelling, BOOLEAN fUnitPriceOnly, case IC_GUN: // add value of the gun uiUnitPrice += (UINT32)( CalcValueOfItemToDealer( gbSelectedArmsDealerID, usItemID, fDealerSelling ) * - ItemConditionModifier(usItemID, pItemObject->bGunStatus) * + ItemConditionModifier(usItemID, pItemObject->ItemData.Gun.bGunStatus) * dModifier ); // if any ammo is loaded - if( pItemObject->usGunAmmoItem != NONE) + if( pItemObject->ItemData.Gun.usGunAmmoItem != NONE) { // if it's regular ammo - if( Item[ pItemObject->usGunAmmoItem ].usItemClass == IC_AMMO ) + if( Item[ pItemObject->ItemData.Gun.usGunAmmoItem ].usItemClass == IC_AMMO ) { // add value of its remaining ammo - uiUnitPrice += (UINT32)( CalcValueOfItemToDealer( gbSelectedArmsDealerID, pItemObject->usGunAmmoItem, fDealerSelling ) * - ItemConditionModifier(pItemObject->usGunAmmoItem, pItemObject->ubGunShotsLeft) * + uiUnitPrice += (UINT32)( CalcValueOfItemToDealer( gbSelectedArmsDealerID, pItemObject->ItemData.Gun.usGunAmmoItem, fDealerSelling ) * + ItemConditionModifier(pItemObject->ItemData.Gun.usGunAmmoItem, pItemObject->ItemData.Gun.ubGunShotsLeft) * dModifier ); } else // assume it's attached ammo (mortar shells, grenades) { // add its value (uses normal status 0-100) - uiUnitPrice += (UINT32)( CalcValueOfItemToDealer( gbSelectedArmsDealerID, pItemObject->usGunAmmoItem, fDealerSelling ) * - ItemConditionModifier(pItemObject->usGunAmmoItem, pItemObject->bGunAmmoStatus) * + uiUnitPrice += (UINT32)( CalcValueOfItemToDealer( gbSelectedArmsDealerID, pItemObject->ItemData.Gun.usGunAmmoItem, fDealerSelling ) * + ItemConditionModifier(pItemObject->ItemData.Gun.usGunAmmoItem, pItemObject->ItemData.Gun.bGunAmmoStatus) * dModifier ); } } @@ -3145,7 +3145,7 @@ UINT32 CalcShopKeeperItemPrice( BOOLEAN fDealerSelling, BOOLEAN fUnitPriceOnly, { // for bullets, ItemConditionModifier will convert the #ShotsLeft into a percentage uiUnitPrice += (UINT32)( CalcValueOfItemToDealer( gbSelectedArmsDealerID, usItemID, fDealerSelling ) * - ItemConditionModifier(usItemID, pItemObject->ubShotsLeft[ubCnt]) * + ItemConditionModifier(usItemID, pItemObject->ItemData.Ammo.ubShotsLeft[ubCnt]) * dModifier ); if ( fUnitPriceOnly ) @@ -3176,7 +3176,7 @@ UINT32 CalcShopKeeperItemPrice( BOOLEAN fDealerSelling, BOOLEAN fUnitPriceOnly, { // for bullets, ItemConditionModifier will convert the #ShotsLeft into a percentage uiUnitPrice += (UINT32)( CalcValueOfItemToDealer( gbSelectedArmsDealerID, usItemID, fDealerSelling ) * - ItemConditionModifier(usItemID, pItemObject->bStatus[ ubCnt ]) * + ItemConditionModifier(usItemID, pItemObject->ItemData.Generic.bStatus[ ubCnt ]) * dModifier ); if ( fUnitPriceOnly ) @@ -3525,7 +3525,7 @@ INT8 AddItemToPlayersOfferArea( UINT8 ubProfileID, INVENTORY_IN_SLOT* pInvSlot, { //Since money is always evaluated PlayersOfferArea[ bCnt ].uiFlags |= ARMS_INV_PLAYERS_ITEM_HAS_VALUE; - PlayersOfferArea[ bCnt ].uiItemPrice = PlayersOfferArea[ bCnt ].ItemObject.uiMoneyAmount; + PlayersOfferArea[ bCnt ].uiItemPrice = PlayersOfferArea[ bCnt ].ItemObject.ItemData.Money.uiMoneyAmount; } gubSkiDirtyLevel = SKI_DIRTY_LEVEL2; @@ -3596,8 +3596,8 @@ void DisplayPlayersOfferArea() sSoldierID = GetSoldierIDFromMercID( PlayersOfferArea[ sCnt ].ubIdOfMercWhoOwnsTheItem ); Assert(sSoldierID != -1); - PlayersOfferArea[ sCnt ].ItemObject.uiMoneyAmount = Menptr[ sSoldierID ].inv[ PlayersOfferArea[ sCnt ].bSlotIdInOtherLocation ].uiMoneyAmount; - PlayersOfferArea[ sCnt ].uiItemPrice = PlayersOfferArea[ sCnt ].ItemObject.uiMoneyAmount; + PlayersOfferArea[ sCnt ].ItemObject.ItemData.Money.uiMoneyAmount = Menptr[ sSoldierID ].inv[ PlayersOfferArea[ sCnt ].bSlotIdInOtherLocation ].ItemData.Money.uiMoneyAmount; + PlayersOfferArea[ sCnt ].uiItemPrice = PlayersOfferArea[ sCnt ].ItemObject.ItemData.Money.uiMoneyAmount; } } else // not money @@ -3734,7 +3734,7 @@ UINT32 CalculateTotalPlayersValue() { //Calculate a price for the item if( Item[ PlayersOfferArea[ ubCnt ].sItemIndex ].usItemClass == IC_MONEY ) - uiTotal += PlayersOfferArea[ ubCnt ].ItemObject.uiMoneyAmount; + uiTotal += PlayersOfferArea[ ubCnt ].ItemObject.ItemData.Money.uiMoneyAmount; else uiTotal += PlayersOfferArea[ ubCnt ].uiItemPrice; } @@ -4058,7 +4058,7 @@ void MovePlayerOfferedItemsOfValueToArmsDealersInventory() if( Item[ PlayersOfferArea[ uiCnt ].sItemIndex ].usItemClass == IC_MONEY ) { //add the money to the dealers 'cash' - gArmsDealerStatus[ gbSelectedArmsDealerID ].uiArmsDealersCash += PlayersOfferArea[ uiCnt ].ItemObject.uiMoneyAmount; + gArmsDealerStatus[ gbSelectedArmsDealerID ].uiArmsDealersCash += PlayersOfferArea[ uiCnt ].ItemObject.ItemData.Money.uiMoneyAmount; } else { @@ -4457,7 +4457,7 @@ INT8 AddInventoryToSkiLocation( INVENTORY_IN_SLOT *pInv, UINT8 ubSpotLocation, U { //Since money is always evaluated PlayersOfferArea[ ubSpotLocation ].uiFlags |= ARMS_INV_PLAYERS_ITEM_HAS_VALUE; - PlayersOfferArea[ ubSpotLocation ].uiItemPrice = PlayersOfferArea[ ubSpotLocation ].ItemObject.uiMoneyAmount; + PlayersOfferArea[ ubSpotLocation ].uiItemPrice = PlayersOfferArea[ ubSpotLocation ].ItemObject.ItemData.Money.uiMoneyAmount; } SetSkiRegionHelpText( &PlayersOfferArea[ ubSpotLocation ], &gPlayersOfferSlotsMouseRegions[ ubSpotLocation ], PLAYERS_OFFER_AREA ); @@ -5759,7 +5759,7 @@ UINT32 CalculateHowMuchMoneyIsInPlayersOfferArea( ) { if( Item[ PlayersOfferArea[ ubCnt ].sItemIndex ].usItemClass == IC_MONEY ) { - uiTotalMoneyValue += PlayersOfferArea[ ubCnt ].ItemObject.uiMoneyAmount; + uiTotalMoneyValue += PlayersOfferArea[ ubCnt ].ItemObject.ItemData.Money.uiMoneyAmount; } } } @@ -5832,7 +5832,7 @@ INT8 GetInvSlotOfUnfullMoneyInMercInventory( SOLDIERTYPE *pSoldier ) for( ubCnt=0; ubCnt < NUM_INV_SLOTS; ubCnt++) { // Look for MONEY only, not Gold or Silver!!! And look for a slot not already full - if( ( pSoldier->inv[ ubCnt ].usItem == MONEY ) && ( pSoldier->inv[ ubCnt ].uiMoneyAmount < MoneySlotLimit( ubCnt ) ) ) + if( ( pSoldier->inv[ ubCnt ].usItem == MONEY ) && ( pSoldier->inv[ ubCnt ].ItemData.Money.uiMoneyAmount < MoneySlotLimit( ubCnt ) ) ) { return( ubCnt ); } @@ -5934,7 +5934,7 @@ void EvaluateItemAddedToPlayersOfferArea( INT8 bSlotID, BOOLEAN fFirstOne ) //if the item is damaged, or is a rocket rifle (which always "need repairing" even at 100%, to reset imprinting) - if( ( PlayersOfferArea[ bSlotID ].ItemObject.bStatus[ 0 ] < 100 ) || fRocketRifleWasEvaluated ) + if( ( PlayersOfferArea[ bSlotID ].ItemObject.ItemData.Generic.bStatus[ 0 ] < 100 ) || fRocketRifleWasEvaluated ) { INT8 bSlotAddedTo; @@ -5960,7 +5960,7 @@ void EvaluateItemAddedToPlayersOfferArea( INT8 bSlotID, BOOLEAN fFirstOne ) // check if the item is really badly damaged if( Item[ ArmsDealerOfferArea[ bSlotAddedTo ].sItemIndex ].usItemClass != IC_AMMO ) { - if( ArmsDealerOfferArea[ bSlotAddedTo ].ItemObject.bStatus[ 0 ] < REALLY_BADLY_DAMAGED_THRESHOLD ) + if( ArmsDealerOfferArea[ bSlotAddedTo ].ItemObject.ItemData.Generic.bStatus[ 0 ] < REALLY_BADLY_DAMAGED_THRESHOLD ) { uiEvalResult = EVAL_RESULT_OK_BUT_REALLY_DAMAGED; } @@ -6676,8 +6676,8 @@ void SplitComplexObjectIntoSubObjects( OBJECTTYPE *pComplexObject ) // Exception: don't do this with rocket launchers, their "shots left" are fake and this screws 'em up! if ( !Item[pComplexObject->usItem].singleshotrocketlauncher ) // Madd rpg - still do this { - pNextObj->ubGunShotsLeft = 0; - pNextObj->usGunAmmoItem = NONE; + pNextObj->ItemData.Gun.ubGunShotsLeft = 0; + pNextObj->ItemData.Gun.usGunAmmoItem = NONE; } /* gunAmmoStatus is currently not being used that way, it's strictly used as a jammed/unjammed, and so should never be 0 @@ -6713,18 +6713,18 @@ void SplitComplexObjectIntoSubObjects( OBJECTTYPE *pComplexObject ) if ( Item [ pComplexObject->usItem ].usItemClass == IC_GUN ) { // and it has ammo/payload - if ( pComplexObject->usGunAmmoItem != NONE ) + if ( pComplexObject->ItemData.Gun.usGunAmmoItem != NONE ) { // if it's bullets - if ( Item[ pComplexObject->usGunAmmoItem ].usItemClass == IC_AMMO ) + if ( Item[ pComplexObject->ItemData.Gun.usGunAmmoItem ].usItemClass == IC_AMMO ) { // and there are some left - if ( pComplexObject->ubGunShotsLeft > 0 ) + if ( pComplexObject->ItemData.Gun.ubGunShotsLeft > 0 ) { // make the bullets into another subobject - CreateItem( pComplexObject->usGunAmmoItem, 100, pNextObj ); + CreateItem( pComplexObject->ItemData.Gun.usGunAmmoItem, 100, pNextObj ); // set how many are left - pNextObj->bStatus[ 0 ] = pComplexObject->ubGunShotsLeft; + pNextObj->ItemData.Generic.bStatus[ 0 ] = pComplexObject->ItemData.Gun.ubGunShotsLeft; pNextObj = &gSubObject[ ++ubNextFreeSlot ]; } @@ -6733,12 +6733,12 @@ void SplitComplexObjectIntoSubObjects( OBJECTTYPE *pComplexObject ) else // non-ammo payload { // make the payload into another subobject - CreateItem( pComplexObject->usGunAmmoItem, pComplexObject->bGunAmmoStatus, pNextObj ); + CreateItem( pComplexObject->ItemData.Gun.usGunAmmoItem, pComplexObject->ItemData.Gun.bGunAmmoStatus, pNextObj ); // if the gun was jammed, fix up the payload's status - if ( pNextObj->bStatus[ 0 ] < 0 ) + if ( pNextObj->ItemData.Generic.bStatus[ 0 ] < 0 ) { - pNextObj->bStatus[ 0 ] *= -1; + pNextObj->ItemData.Generic.bStatus[ 0 ] *= -1; } pNextObj = &gSubObject[ ++ubNextFreeSlot ]; @@ -6777,7 +6777,7 @@ void SplitComplexObjectIntoSubObjects( OBJECTTYPE *pComplexObject ) // make each item in the stack into a separate subobject for( ubCnt = 0; ubCnt < pComplexObject->ubNumberOfObjects; ubCnt++ ) { - CreateItem( pComplexObject->usItem, pComplexObject->bStatus[ ubCnt ], pNextObj ); + CreateItem( pComplexObject->usItem, pComplexObject->ItemData.Generic.bStatus[ ubCnt ], pNextObj ); // advance to next available subobject pNextObj = &gSubObject[ ++ubNextFreeSlot ]; @@ -6807,7 +6807,7 @@ void CountSubObjectsInObject( OBJECTTYPE *pComplexObject, UINT8 *pubTotalSubObje // is it in need of fixing, and also repairable by this dealer? // A jammed gun with a 100% status is NOT repairable - shouldn't ever happen - if ( ( gSubObject[ ubSubObject ].bStatus[ 0 ] != 100 ) && + if ( ( gSubObject[ ubSubObject ].ItemData.Generic.bStatus[ 0 ] != 100 ) && CanDealerRepairItem( gbSelectedArmsDealerID, gSubObject[ ubSubObject ].usItem ) ) { @@ -7040,7 +7040,7 @@ BOOLEAN SKITryToAddInvToMercsInventory( INVENTORY_IN_SLOT *pInv, SOLDIERTYPE *pS PlaceObject( pSoldier, bMoneyInvPos, &( pInv->ItemObject ) ); // if the money is all gone - if ( pInv->ItemObject.uiMoneyAmount == 0 ) + if ( pInv->ItemObject.ItemData.Money.uiMoneyAmount == 0 ) { // we've been succesful! return(TRUE); @@ -7635,7 +7635,7 @@ UINT32 EvaluateInvSlot( INVENTORY_IN_SLOT *pInvSlot ) // check if the item is really badly damaged if( Item[ pInvSlot->sItemIndex ].usItemClass != IC_AMMO ) { - if( pInvSlot->ItemObject.bStatus[ 0 ] < REALLY_BADLY_DAMAGED_THRESHOLD ) + if( pInvSlot->ItemObject.ItemData.Generic.bStatus[ 0 ] < REALLY_BADLY_DAMAGED_THRESHOLD ) { uiEvalResult = EVAL_RESULT_OK_BUT_REALLY_DAMAGED; } diff --git a/Tactical/SkillCheck.cpp b/Tactical/SkillCheck.cpp index 58f652a0..d1708e3a 100644 --- a/Tactical/SkillCheck.cpp +++ b/Tactical/SkillCheck.cpp @@ -258,7 +258,7 @@ INT32 SkillCheck( SOLDIERTYPE * pSoldier, INT8 bReason, INT8 bChanceMod ) // this should never happen, but might as well check... iSkill = 0; } - iSkill = iSkill * pSoldier->inv[bSlot].bStatus[0] / 100; + iSkill = iSkill * pSoldier->inv[bSlot].ItemData.Generic.bStatus[0] / 100; break; case ATTACHING_DETONATOR_CHECK: case ATTACHING_REMOTE_DETONATOR_CHECK: diff --git a/Tactical/Soldier Add.cpp b/Tactical/Soldier Add.cpp index 79ab6131..e55a0aa6 100644 --- a/Tactical/Soldier Add.cpp +++ b/Tactical/Soldier Add.cpp @@ -1156,8 +1156,8 @@ BOOLEAN InternalAddSoldierToSector( UINT8 ubID, BOOLEAN fCalculateDirection, BOO { if( pSoldier->sInsertionGridNo == NOWHERE ) { //Add the soldier to the respective entrypoint. This is an error condition. - - + // So treat it like an error already then! + Assert(0); } if( pSoldier->uiStatusFlags & SOLDIER_VEHICLE ) { diff --git a/Tactical/Soldier Ani.cpp b/Tactical/Soldier Ani.cpp index 503dc588..cf0c5331 100644 --- a/Tactical/Soldier Ani.cpp +++ b/Tactical/Soldier Ani.cpp @@ -3749,7 +3749,7 @@ BOOLEAN CheckForImproperFireGunEnd( SOLDIERTYPE *pSoldier ) } // Check single hand for jammed status, ( or ammo is out.. ) - if ( pSoldier->inv[ HANDPOS ].bGunAmmoStatus < 0 || pSoldier->inv[ HANDPOS ].ubGunShotsLeft == 0 ) + if ( pSoldier->inv[ HANDPOS ].ItemData.Gun.bGunAmmoStatus < 0 || pSoldier->inv[ HANDPOS ].ItemData.Gun.ubGunShotsLeft == 0 ) { // If we have 2 pistols, donot go back! if ( Item[ pSoldier->inv[ SECONDHANDPOS ].usItem ].usItemClass != IC_GUN ) diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 97b0725a..3c824c5c 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -3283,7 +3283,7 @@ void SetSoldierGridNo( SOLDIERTYPE *pSoldier, INT16 sNewGridNo, BOOLEAN fForceRe BOOLEAN fSetGassed = TRUE; // If we have a functioning gas mask... - if ( FindGasMask ( pSoldier ) != NO_SLOT && pSoldier->inv[ HEAD1POS ].bStatus[ 0 ] >= GASMASK_MIN_STATUS ) + if ( FindGasMask ( pSoldier ) != NO_SLOT && pSoldier->inv[ HEAD1POS ].ItemData.Generic.bStatus[ 0 ] >= GASMASK_MIN_STATUS ) { fSetGassed = FALSE; } @@ -4092,7 +4092,7 @@ void EVENT_SoldierGotHit( SOLDIERTYPE *pSoldier, UINT16 usWeaponIndex, INT16 sDa } // callahan update end - else if ( Item[ usWeaponIndex ].usItemClass & ( IC_GUN | IC_THROWING_KNIFE ) && AmmoTypes[MercPtrs[ubAttackerID]->inv[MercPtrs[ubAttackerID]->ubAttackingHand ].ubGunAmmoType].explosionSize <= 1) + else if ( Item[ usWeaponIndex ].usItemClass & ( IC_GUN | IC_THROWING_KNIFE ) && AmmoTypes[MercPtrs[ubAttackerID]->inv[MercPtrs[ubAttackerID]->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].explosionSize <= 1) { if ( ubSpecial == FIRE_WEAPON_SLEEP_DART_SPECIAL ) { @@ -4151,7 +4151,7 @@ void EVENT_SoldierGotHit( SOLDIERTYPE *pSoldier, UINT16 usWeaponIndex, INT16 sDa } // marke added one 'or' for explosive ammo. variation of: AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ubGunAmmoType].explosionSize > 1 // extracting attacker´s ammo type - else if ( Item[ usWeaponIndex ].usItemClass & IC_EXPLOSV || AmmoTypes[MercPtrs[ubAttackerID]->inv[MercPtrs[ubAttackerID]->ubAttackingHand ].ubGunAmmoType].explosionSize > 1) + else if ( Item[ usWeaponIndex ].usItemClass & IC_EXPLOSV || AmmoTypes[MercPtrs[ubAttackerID]->inv[MercPtrs[ubAttackerID]->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].explosionSize > 1) { INT8 bDeafValue; @@ -11736,8 +11736,8 @@ BOOLEAN IsValidSecondHandShot( SOLDIERTYPE *pSoldier ) !pSoldier->bDoBurst && !Item[pSoldier->inv[ HANDPOS ].usItem].grenadelauncher && Item[ pSoldier->inv[HANDPOS].usItem ].usItemClass == IC_GUN && - pSoldier->inv[SECONDHANDPOS].bGunStatus >= USABLE && - pSoldier->inv[SECONDHANDPOS].ubGunShotsLeft > 0 ) + pSoldier->inv[SECONDHANDPOS].ItemData.Gun.bGunStatus >= USABLE && + pSoldier->inv[SECONDHANDPOS].ItemData.Gun.ubGunShotsLeft > 0 ) { return( TRUE ); } @@ -11753,7 +11753,7 @@ BOOLEAN IsValidSecondHandShotForReloadingPurposes( SOLDIERTYPE *pSoldier ) !pSoldier->bDoBurst && !Item[pSoldier->inv[ HANDPOS ].usItem].grenadelauncher && Item[ pSoldier->inv[HANDPOS].usItem ].usItemClass == IC_GUN && - pSoldier->inv[SECONDHANDPOS].bGunStatus >= USABLE //&& + pSoldier->inv[SECONDHANDPOS].ItemData.Gun.bGunStatus >= USABLE //&& // pSoldier->inv[SECONDHANDPOS].ubGunShotsLeft > 0 && // gAnimControl[ pSoldier->usAnimState ].ubEndHeight != ANIM_PRONE ) ) diff --git a/Tactical/Soldier Create.cpp b/Tactical/Soldier Create.cpp index 4f335d89..81ee30b5 100644 --- a/Tactical/Soldier Create.cpp +++ b/Tactical/Soldier Create.cpp @@ -354,7 +354,7 @@ SOLDIERTYPE* TacticalCreateSoldier( SOLDIERCREATE_STRUCT *pCreateStruct, UINT8 * } } - // Copy the items over for thew soldier, only if we have a valid profile id! + // Copy the items over for the soldier, only if we have a valid profile id! if ( pCreateStruct->ubProfile != NO_PROFILE ) CopyProfileItems( &Soldier, pCreateStruct ); @@ -2712,12 +2712,12 @@ void CopyProfileItems( SOLDIERTYPE *pSoldier, SOLDIERCREATE_STRUCT *pCreateStruc if ( uiMoneyLeft > uiMoneyLimitInSlot ) { // fill pocket with money - pSoldier->inv[ bSlot ].uiMoneyAmount = uiMoneyLimitInSlot; + pSoldier->inv[ bSlot ].ItemData.Money.uiMoneyAmount = uiMoneyLimitInSlot; uiMoneyLeft -= uiMoneyLimitInSlot; } else { - pSoldier->inv[ bSlot ].uiMoneyAmount = uiMoneyLeft; + pSoldier->inv[ bSlot ].ItemData.Money.uiMoneyAmount = uiMoneyLeft; // done! break; } diff --git a/Tactical/Soldier Init List.cpp b/Tactical/Soldier Init List.cpp index e1626dea..f3ae808c 100644 --- a/Tactical/Soldier Init List.cpp +++ b/Tactical/Soldier Init List.cpp @@ -541,19 +541,21 @@ BOOLEAN AddPlacementToWorld( SOLDIERINITNODE *curr, GROUP *pGroup = NULL ) if (curr->pBasicPlacement->bBodyType == TANK_NW || curr->pBasicPlacement->bBodyType == TANK_NE) { - while (1) + ROTTING_CORPSE *pCorpse; + //while (1) + do { - ROTTING_CORPSE *pCorpse = GetCorpseAtGridNo( curr->pBasicPlacement->usStartingGridNo, 0); // I assume we don't find tanks on the roof + pCorpse = GetCorpseAtGridNo( curr->pBasicPlacement->usStartingGridNo, 0); // I assume we don't find tanks on the roof if (pCorpse) { // Assume this is a dead tank and have the replacement tank haul it away RemoveCorpse( pCorpse->iID); } - else - { - break; - } - } + //else + //{ + //break; + //} + } while (pCorpse); } DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddPlacementToWorld: decide on placement")); diff --git a/Tactical/Soldier Profile.cpp b/Tactical/Soldier Profile.cpp index 4d032f5f..5b776770 100644 --- a/Tactical/Soldier Profile.cpp +++ b/Tactical/Soldier Profile.cpp @@ -611,7 +611,7 @@ void MakeRemainingTerroristsTougher( void ) DeleteObj( &Object ); Object.usItem = usNewItem; - Object.bStatus[ 0 ] = 100; + Object.ItemData.Generic.bStatus[ 0 ] = 100; for ( ubLoop = 0; ubLoop < NUM_TERRORISTS; ubLoop++ ) { @@ -745,7 +745,7 @@ void MakeRemainingAssassinsTougher( void ) DeleteObj( &Object ); Object.usItem = usNewItem; - Object.bStatus[ 0 ] = 100; + Object.ItemData.Generic.bStatus[ 0 ] = 100; for ( ubLoop = 0; ubLoop < NUM_ASSASSINS; ubLoop++ ) { diff --git a/Tactical/Spread Burst.cpp b/Tactical/Spread Burst.cpp index 5ae7965c..706129c2 100644 --- a/Tactical/Spread Burst.cpp +++ b/Tactical/Spread Burst.cpp @@ -144,7 +144,7 @@ void PickBurstLocations( SOLDIERTYPE *pSoldier ) pSoldier->bDoAutofire++; sAPCosts = CalcTotalAPsToAttack( pSoldier, gsBurstLocations[0].sGridNo, TRUE, 0); } - while(EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) && pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft >= pSoldier->bDoAutofire && gbNumBurstLocations >= pSoldier->bDoAutofire); + while(EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) && pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft >= pSoldier->bDoAutofire && gbNumBurstLocations >= pSoldier->bDoAutofire); pSoldier->bDoAutofire--; ubShotsPerBurst = __min(pSoldier->bDoAutofire,MAX_BURST_SPREAD_TARGETS); diff --git a/Tactical/Tactical Save.cpp b/Tactical/Tactical Save.cpp index e8978bbd..05d5efb2 100644 --- a/Tactical/Tactical Save.cpp +++ b/Tactical/Tactical Save.cpp @@ -2742,10 +2742,10 @@ BOOLEAN AddDeadSoldierToUnLoadedSector( INT16 sMapX, INT16 sMapY, UINT8 bMapZ, S if ( Item[pSoldier->inv[i].usItem].damageable ) // Madd: drop crappier items on higher difficulty levels { - pSoldier->inv[i].bStatus[0] -= (gGameOptions.ubDifficultyLevel - 1) * Random(20); - pSoldier->inv[i].bStatus[0] = max(pSoldier->inv[i].bStatus[0],1); // never below 1% + pSoldier->inv[i].ItemData.Generic.bStatus[0] -= (gGameOptions.ubDifficultyLevel - 1) * Random(20); + pSoldier->inv[i].ItemData.Generic.bStatus[0] = max(pSoldier->inv[i].ItemData.Generic.bStatus[0],1); // never below 1% } - memcpy( &(pWorldItems[ bCount ].o), &pSoldier->inv[i], sizeof( OBJECTTYPE ) ); + pWorldItems[ bCount ].o = pSoldier->inv[i]; bCount++; } } diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index f1673a9a..eba20565 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -2587,13 +2587,13 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) if (( Item[ gWorldItems[ uiLoop ].o.usItem ].usItemClass == IC_GUN ) && (gGameExternalOptions.gfShiftFUnloadWeapons == TRUE) )//item is a gun and unloading is allowed { //Remove magazine - if ( (gWorldItems[ uiLoop ].o.usGunAmmoItem != NONE) && (gWorldItems[ uiLoop ].o.ubGunShotsLeft > 0) ) + if ( (gWorldItems[ uiLoop ].o.ItemData.Gun.usGunAmmoItem != NONE) && (gWorldItems[ uiLoop ].o.ItemData.Gun.ubGunShotsLeft > 0) ) { OBJECTTYPE newObj; //Create object - CreateItem(gWorldItems[ uiLoop ].o.usGunAmmoItem, 100, &newObj); - newObj.ubShotsLeft[0] = gWorldItems[ uiLoop ].o.ubGunShotsLeft; - gWorldItems[ uiLoop ].o.ubGunShotsLeft = 0; - gWorldItems[ uiLoop ].o.usGunAmmoItem = NONE; + CreateItem(gWorldItems[ uiLoop ].o.ItemData.Gun.usGunAmmoItem, 100, &newObj); + newObj.ItemData.Ammo.ubShotsLeft[0] = gWorldItems[ uiLoop ].o.ItemData.Gun.ubGunShotsLeft; + gWorldItems[ uiLoop ].o.ItemData.Gun.ubGunShotsLeft = 0; + gWorldItems[ uiLoop ].o.ItemData.Gun.usGunAmmoItem = NONE; // put it on the ground AddItemToPool( gWorldItems[ uiLoop ].sGridNo, &newObj, 1, gWorldItems[ uiLoop ].ubLevel, 0 , -1 ); @@ -3103,10 +3103,10 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) tempStatus = pObj->bAttachStatus[bSlot3]; // Replace helmet attachment with face slot pObj->usAttachItem[bSlot3] = pTeamSoldier->inv[bSlot1].usItem; - pObj->bAttachStatus[bSlot3] = pTeamSoldier->inv[bSlot1].bStatus[0]; + pObj->bAttachStatus[bSlot3] = pTeamSoldier->inv[bSlot1].ItemData.Generic.bStatus[0]; // Replace face slot with helmet attachment from temp pTeamSoldier->inv[bSlot1].usItem = tempItem; - pTeamSoldier->inv[bSlot1].bStatus[0] = tempStatus; + pTeamSoldier->inv[bSlot1].ItemData.Generic.bStatus[0] = tempStatus; } else if ( bSlot2 != ITEM_NOT_FOUND ) { @@ -3146,10 +3146,10 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) tempStatus = pObj->bAttachStatus[bSlot3]; // Replace helmet attachment with face slot pObj->usAttachItem[bSlot3] = pTeamSoldier->inv[bSlot1].usItem; - pObj->bAttachStatus[bSlot3] = pTeamSoldier->inv[bSlot1].bStatus[0]; + pObj->bAttachStatus[bSlot3] = pTeamSoldier->inv[bSlot1].ItemData.Generic.bStatus[0]; // Replace face slot with helmet attachment from temp pTeamSoldier->inv[bSlot1].usItem = tempItem; - pTeamSoldier->inv[bSlot1].bStatus[0] = tempStatus; + pTeamSoldier->inv[bSlot1].ItemData.Generic.bStatus[0] = tempStatus; } else if ( bSlot2 != ITEM_NOT_FOUND ) { @@ -3302,7 +3302,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) { pGun = &(pTeamSoldier->inv[bLoop2]); //if magazine is not full - if ( pGun->ubGunShotsLeft < GetMagSize( pGun ) ) + if ( pGun->ItemData.Gun.ubGunShotsLeft < GetMagSize( pGun ) ) { // Search for ammo in sector @@ -3317,12 +3317,12 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) if ( CompatibleAmmoForGun( pAmmo, pGun ) ) // can use the ammo with this gun { // same ammo type in gun and magazine - if ( Magazine[Item[pGun->usGunAmmoItem].ubClassIndex].ubAmmoType == Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType ) + if ( Magazine[Item[pGun->ItemData.Gun.usGunAmmoItem].ubClassIndex].ubAmmoType == Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType ) { ReloadGun( pTeamSoldier, pGun, pAmmo ); } - if (pAmmo->ubShotsLeft[0] == 0) + if (pAmmo->ItemData.Ammo.ubShotsLeft[0] == 0) { RemoveItemFromPool( gWorldItems[ uiLoop ].sGridNo, uiLoop, gWorldItems[ uiLoop ].ubLevel ); } @@ -3353,7 +3353,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) pGun = &(pTeamSoldier->inv[HANDPOS]); //magazine is not full - if ( pGun->ubGunShotsLeft < GetMagSize( pGun ) ) + if ( pGun->ItemData.Gun.ubGunShotsLeft < GetMagSize( pGun ) ) { AutoReload( pTeamSoldier ); } @@ -3367,7 +3367,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) { pGun = &(pTeamSoldier->inv[bLoop2]); //if magazine is not full - if ( pGun->ubGunShotsLeft < GetMagSize( pGun ) ) + if ( pGun->ItemData.Gun.ubGunShotsLeft < GetMagSize( pGun ) ) { // Search for ammo in soldier inventory @@ -3380,7 +3380,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) if ( CompatibleAmmoForGun( pAmmo, pGun ) ) // can use the ammo with this gun { // same ammo type in gun and magazine - if ( Magazine[Item[pGun->usGunAmmoItem].ubClassIndex].ubAmmoType == Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType ) + if ( Magazine[Item[pGun->ItemData.Gun.usGunAmmoItem].ubClassIndex].ubAmmoType == Magazine[Item[pAmmo->usItem].ubClassIndex].ubAmmoType ) { ReloadGun( pTeamSoldier, pGun, pAmmo ); @@ -4689,7 +4689,7 @@ void GrenadeTest1() { OBJECTTYPE Object; Object.usItem = MUSTARD_GRENADE; - Object.bStatus[ 0 ] = 100; + Object.ItemData.Generic.bStatus[ 0 ] = 100; Object.ubNumberOfObjects = 1; CreatePhysicalObject( &Object, 60, (FLOAT)(sX * CELL_X_SIZE), (FLOAT)(sY * CELL_Y_SIZE ), 256, -20, 20, 158, NOBODY, THROW_ARM_ITEM, 0, FALSE ); } @@ -4703,7 +4703,7 @@ void GrenadeTest2() { OBJECTTYPE Object; Object.usItem = HAND_GRENADE; - Object.bStatus[ 0 ] = 100; + Object.ItemData.Generic.bStatus[ 0 ] = 100; Object.ubNumberOfObjects = 1; CreatePhysicalObject( &Object, 60, (FLOAT)(sX * CELL_X_SIZE), (FLOAT)(sY * CELL_Y_SIZE ), 256, 0, -30, 158, NOBODY, THROW_ARM_ITEM, 0, FALSE ); } @@ -4717,7 +4717,7 @@ void GrenadeTest3() { OBJECTTYPE Object; Object.usItem = HAND_GRENADE; - Object.bStatus[ 0 ] = 100; + Object.ItemData.Generic.bStatus[ 0 ] = 100; Object.ubNumberOfObjects = 1; CreatePhysicalObject( &Object, 60, (FLOAT)(sX * CELL_X_SIZE), (FLOAT)(sY * CELL_Y_SIZE ), 256, -10, 10, 158, NOBODY, THROW_ARM_ITEM, 0, FALSE ); } diff --git a/Tactical/UI Cursors.cpp b/Tactical/UI Cursors.cpp index ae86af35..86007da7 100644 --- a/Tactical/UI Cursors.cpp +++ b/Tactical/UI Cursors.cpp @@ -381,13 +381,13 @@ UINT8 HandleActivatedTargetCursor( SOLDIERTYPE *pSoldier, UINT16 usMapPos, BOOLE pSoldier->bDoAutofire++; sAPCosts = CalcTotalAPsToAttack( pSoldier, usMapPos, TRUE, 0); } - while(EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) && sAPCosts == sCurAPCosts && pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft >= pSoldier->bDoAutofire); + while(EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) && sAPCosts == sCurAPCosts && pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft >= pSoldier->bDoAutofire); pSoldier->bDoAutofire--; } gfUIAutofireBulletCount = TRUE; gsBulletCount = pSoldier->bDoAutofire; - gsTotalBulletCount = pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft; + gsTotalBulletCount = pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft; if(pSoldier->autofireLastStep) //set the orange tint on the numbers if we at the last step gTintBulletCounts = TRUE; @@ -536,7 +536,7 @@ UINT8 HandleActivatedTargetCursor( SOLDIERTYPE *pSoldier, UINT16 usMapPos, BOOLE pSoldier->bDoAutofire++; sAPCosts = CalcTotalAPsToAttack( pSoldier, gsBurstLocations[0].sGridNo, TRUE, 0); } - while(EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) && pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft >= pSoldier->bDoAutofire && gbNumBurstLocations >= pSoldier->bDoAutofire); + while(EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) && pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft >= pSoldier->bDoAutofire && gbNumBurstLocations >= pSoldier->bDoAutofire); pSoldier->bDoAutofire--; gsCurrentActionPoints = CalcTotalAPsToAttack( pSoldier, gsBurstLocations[0].sGridNo, TRUE, 0 ); @@ -2065,11 +2065,11 @@ void HandleRightClickAdjustCursor( SOLDIERTYPE *pSoldier, INT16 usMapPos ) } - if(pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft > pSoldier->bDoAutofire ) + if(pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft > pSoldier->bDoAutofire ) { //Calculate how many bullets we need to fire to add at least one more AP sAPCosts = sCurAPCosts = CalcTotalAPsToAttack( pSoldier, usMapPos, TRUE, 0); - while(EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) && sAPCosts <= sCurAPCosts && pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft > pSoldier->bDoAutofire) //Increment the bullet count until we run out of APs or we spend the whole AP + while(EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) && sAPCosts <= sCurAPCosts && pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft > pSoldier->bDoAutofire) //Increment the bullet count until we run out of APs or we spend the whole AP { pSoldier->bDoAutofire++; sAPCosts = CalcTotalAPsToAttack( pSoldier, usMapPos, TRUE, 0); @@ -2084,7 +2084,7 @@ void HandleRightClickAdjustCursor( SOLDIERTYPE *pSoldier, INT16 usMapPos ) pSoldier->bDoAutofire++; sAPCosts = CalcTotalAPsToAttack( pSoldier, usMapPos, TRUE, 0); } - while(EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) && sAPCosts == sCurAPCosts && pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft >= pSoldier->bDoAutofire); + while(EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) && sAPCosts == sCurAPCosts && pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft >= pSoldier->bDoAutofire); pSoldier->bDoAutofire--; sAPCosts = CalcTotalAPsToAttack( pSoldier, usMapPos, TRUE, 0); diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index d36a241d..79a660aa 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -961,7 +961,7 @@ INT32 EffectiveArmour( OBJECTTYPE * pObj ) return( 0 ); } iValue = Armour[ Item[pObj->usItem].ubClassIndex ].ubProtection; - iValue = iValue * pObj->bStatus[0] * Armour[ Item[pObj->usItem].ubClassIndex ].ubCoverage / 10000; + iValue = iValue * pObj->ItemData.Generic.bStatus[0] * Armour[ Item[pObj->usItem].ubClassIndex ].ubCoverage / 10000; // bPlate = FindAttachment( pObj, CERAMIC_PLATES ); bPlate = FindFirstArmourAttachment( pObj ); @@ -1057,7 +1057,7 @@ INT32 ExplosiveEffectiveArmour( OBJECTTYPE * pObj ) return( 0 ); } iValue = Armour[ Item[pObj->usItem].ubClassIndex ].ubProtection; - iValue = iValue * pObj->bStatus[0] * Armour[ Item[pObj->usItem].ubClassIndex ].ubCoverage / 10000; + iValue = iValue * pObj->ItemData.Generic.bStatus[0] * Armour[ Item[pObj->usItem].ubClassIndex ].ubCoverage / 10000; if ( Item[pObj->usItem].flakjacket ) { // increase value for flak jackets! @@ -1156,13 +1156,13 @@ BOOLEAN CheckForGunJam( SOLDIERTYPE * pSoldier ) if ( Item[pSoldier->usAttackingWeapon].usItemClass == IC_GUN && !EXPLOSIVE_GUN( pSoldier->usAttackingWeapon ) ) { pObj = &(pSoldier->inv[pSoldier->ubAttackingHand]); - if (pObj->bGunAmmoStatus > 0) + if (pObj->ItemData.Gun.bGunAmmoStatus > 0) { // gun might jam, figure out the chance //iChance = (80 - pObj->bGunStatus); //rain - iChance = (80 - pObj->bGunStatus) + gGameExternalOptions.ubWeaponReliabilityReductionPerRainIntensity * gbCurrentRainIntensity; + iChance = (80 - pObj->ItemData.Gun.bGunStatus) + gGameExternalOptions.ubWeaponReliabilityReductionPerRainIntensity * gbCurrentRainIntensity; //end rain @@ -1198,7 +1198,7 @@ BOOLEAN CheckForGunJam( SOLDIERTYPE * pSoldier ) gfNextFireJam = FALSE; // jam! negate the gun ammo status. - pObj->bGunAmmoStatus *= -1; + pObj->ItemData.Gun.bGunAmmoStatus *= -1; // Deduct AMMO! DeductAmmo( pSoldier, pSoldier->ubAttackingHand ); @@ -1207,14 +1207,14 @@ BOOLEAN CheckForGunJam( SOLDIERTYPE * pSoldier ) return( TRUE ); } } - else if (pObj->bGunAmmoStatus < 0) + else if (pObj->ItemData.Gun.bGunAmmoStatus < 0) { // try to unjam gun - iResult = SkillCheck( pSoldier, UNJAM_GUN_CHECK, (INT8) ((Item[pObj->usItem].bReliability + Item[pObj->usGunAmmoItem].bReliability)* 4) ); + iResult = SkillCheck( pSoldier, UNJAM_GUN_CHECK, (INT8) ((Item[pObj->usItem].bReliability + Item[pObj->ItemData.Gun.usGunAmmoItem].bReliability)* 4) ); if (iResult > 0) { // yay! unjammed the gun - pObj->bGunAmmoStatus *= -1; + pObj->ItemData.Gun.bGunAmmoStatus *= -1; // MECHANICAL/DEXTERITY GAIN: Unjammed a gun StatChange( pSoldier, MECHANAMT, 5, FALSE ); @@ -1581,7 +1581,7 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) else { // ONLY DEDUCT FOR THE FIRST HAND when doing two-pistol attacks - if ( IsValidSecondHandShot( pSoldier ) && pSoldier->inv[ HANDPOS ].bGunStatus >= USABLE && pSoldier->inv[HANDPOS].bGunAmmoStatus > 0 ) + if ( IsValidSecondHandShot( pSoldier ) && pSoldier->inv[ HANDPOS ].ItemData.Gun.bGunStatus >= USABLE && pSoldier->inv[HANDPOS].ItemData.Gun.bGunAmmoStatus > 0 ) { // only deduct APs when the main gun fires if ( pSoldier->ubAttackingHand == HANDPOS ) @@ -1746,7 +1746,7 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) DeductAmmo( pSoldier, pSoldier->ubAttackingHand ); // ATE: Check if we should say quote... - if ( pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft == 0 && !Item[pSoldier->usAttackingWeapon].rocketlauncher ) + if ( pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft == 0 && !Item[pSoldier->usAttackingWeapon].rocketlauncher ) { if ( pSoldier->bTeam == gbPlayerNum ) { @@ -1777,7 +1777,7 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) // add base pts for taking a shot, whether it hits or misses usExpGain += 3; - if ( IsValidSecondHandShot( pSoldier ) && pSoldier->inv[ HANDPOS ].bGunStatus >= USABLE && pSoldier->inv[HANDPOS].bGunAmmoStatus > 0 ) + if ( IsValidSecondHandShot( pSoldier ) && pSoldier->inv[ HANDPOS ].ItemData.Gun.bGunStatus >= USABLE && pSoldier->inv[HANDPOS].ItemData.Gun.bGunAmmoStatus > 0 ) { // reduce exp gain for two pistol shooting since both shots give xp usExpGain = (usExpGain * 2) / 3; @@ -1808,7 +1808,7 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("UseGun: Muzzle flash = %d",pSoldier->fMuzzleFlash)); - if ( AmmoTypes[pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunAmmoType].numberOfBullets > 1 ) + if ( AmmoTypes[pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].numberOfBullets > 1 ) fBuckshot = TRUE; //switch ( pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunAmmoType ) @@ -1875,7 +1875,7 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) { if ( Item[usItemNum].singleshotrocketlauncher ) { - CreateItem( Item[usItemNum].discardedlauncheritem , pSoldier->inv[ HANDPOS ].bStatus[ 0 ],&(pSoldier->inv[ HANDPOS ] ) ); + CreateItem( Item[usItemNum].discardedlauncheritem , pSoldier->inv[ HANDPOS ].ItemData.Generic.bStatus[ 0 ],&(pSoldier->inv[ HANDPOS ] ) ); DirtyMercPanelInterface( pSoldier, DIRTYLEVEL2 ); IgniteExplosion( pSoldier->ubID, (INT16)CenterX( pSoldier->sGridNo ), (INT16)CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, C1, pSoldier->bLevel ); } @@ -1883,8 +1883,8 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) { DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("StructureHit: RPG7 item: %d, Ammo: %d",pSoldier->inv[HANDPOS].usItem , pSoldier->inv[HANDPOS].usGunAmmoItem ) ); - IgniteExplosion( pSoldier->ubID, (INT16)CenterX( pSoldier->sGridNo ), (INT16)CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, pSoldier->inv[pSoldier->ubAttackingHand ].usGunAmmoItem, pSoldier->bLevel ); - pSoldier->inv[pSoldier->ubAttackingHand ].usGunAmmoItem = NONE; + IgniteExplosion( pSoldier->ubID, (INT16)CenterX( pSoldier->sGridNo ), (INT16)CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, pSoldier->inv[pSoldier->ubAttackingHand ].ItemData.Gun.usGunAmmoItem, pSoldier->bLevel ); + pSoldier->inv[pSoldier->ubAttackingHand ].ItemData.Gun.usGunAmmoItem = NONE; } // Reduce again for attack end 'cause it has been incremented for a normal attack // @@ -1912,7 +1912,7 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) { if ( Item[usItemNum].singleshotrocketlauncher ) { - CreateItem( Item[usItemNum].discardedlauncheritem, pSoldier->inv[ HANDPOS ].bStatus[ 0 ], &(pSoldier->inv[ HANDPOS ] ) ); + CreateItem( Item[usItemNum].discardedlauncheritem, pSoldier->inv[ HANDPOS ].ItemData.Generic.bStatus[ 0 ], &(pSoldier->inv[ HANDPOS ] ) ); DirtyMercPanelInterface( pSoldier, DIRTYLEVEL2 ); } @@ -1964,14 +1964,14 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) if ( Item[usItemNum].usItemClass == IC_GUN ) { OBJECTTYPE *pGun = &(pSoldier->inv[pSoldier->ubAttackingHand]); - ammoReliability = Item[pGun->usGunAmmoItem].bReliability; + ammoReliability = Item[pGun->ItemData.Gun.usGunAmmoItem].bReliability; } uiDepreciateTest = BASIC_DEPRECIATE_CHANCE + 3 * (Item[ usItemNum ].bReliability + ammoReliability); - if ( !PreRandom( uiDepreciateTest ) && ( pSoldier->inv[ pSoldier->ubAttackingHand ].bStatus[0] > 1) ) + if ( !PreRandom( uiDepreciateTest ) && ( pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Generic.bStatus[0] > 1) ) { - pSoldier->inv[ pSoldier->ubAttackingHand ].bStatus[ 0 ]--; + pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Generic.bStatus[ 0 ]--; } // reduce monster smell (gunpowder smell) @@ -1982,7 +1982,7 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) // manual recharge if (Weapon[Item[usItemNum].ubClassIndex].APsToReloadManually > 0) - pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunState &= ~GS_CARTRIDGE_IN_CHAMBER; + pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunState &= ~GS_CARTRIDGE_IN_CHAMBER; // DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("UseGun: done")); return( TRUE ); @@ -2046,7 +2046,7 @@ BOOLEAN UseBlade( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) iImpact = HTHImpact( pSoldier, pTargetSoldier, (iHitChance - iDiceRoll), TRUE ); // modify this by the knife's condition (if it's dull, not much good) - iImpact = ( iImpact * WEAPON_STATUS_MOD(pSoldier->inv[pSoldier->ubAttackingHand].bStatus[0]) ) / 100; + iImpact = ( iImpact * WEAPON_STATUS_MOD(pSoldier->inv[pSoldier->ubAttackingHand].ItemData.Generic.bStatus[0]) ) / 100; // modify by hit location AdjustImpactByHitLocation( iImpact, pSoldier->bAimShotLocation, &iImpact, &iImpactForCrits ); @@ -2063,17 +2063,17 @@ BOOLEAN UseBlade( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) iImpact = 1; } - if ( pSoldier->inv[ pSoldier->ubAttackingHand ].bStatus[ 0 ] > USABLE ) + if ( pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Generic.bStatus[ 0 ] > USABLE ) { bMaxDrop = (iImpact / 20); // the duller they get, the slower they get any worse... - bMaxDrop = __min( bMaxDrop, pSoldier->inv[ pSoldier->ubAttackingHand ].bStatus[ 0 ] / 10 ); + bMaxDrop = __min( bMaxDrop, pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Generic.bStatus[ 0 ] / 10 ); // as long as its still > USABLE, it drops another point 1/2 the time bMaxDrop = __max( bMaxDrop, 2 ); - pSoldier->inv[ pSoldier->ubAttackingHand ].bStatus[ 0 ] -= (INT8) Random( bMaxDrop ); // 0 to (maxDrop - 1) + pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Generic.bStatus[ 0 ] -= (INT8) Random( bMaxDrop ); // 0 to (maxDrop - 1) } // Send event for getting hit @@ -2775,7 +2775,7 @@ BOOLEAN DoSpecialEffectAmmoMiss( UINT8 ubAttackerID, INT16 sGridNo, INT16 sXPos, UINT8 ubAmmoType; UINT16 usItem; - ubAmmoType = MercPtrs[ ubAttackerID ]->inv[ MercPtrs[ ubAttackerID ]->ubAttackingHand ].ubGunAmmoType; + ubAmmoType = MercPtrs[ ubAttackerID ]->inv[ MercPtrs[ ubAttackerID ]->ubAttackingHand ].ItemData.Gun.ubGunAmmoType; usItem = MercPtrs[ ubAttackerID ]->inv[ MercPtrs[ ubAttackerID ]->ubAttackingHand ].usItem; memset( &AniParams, 0, sizeof( ANITILE_PARAMS ) ); @@ -2938,14 +2938,14 @@ void WeaponHit( UINT16 usSoldierID, UINT16 usWeaponIndex, INT16 sDamage, INT16 s MakeNoise( ubAttackerID, pTargetSoldier->sGridNo, pTargetSoldier->bLevel, gpWorldLevelData[pTargetSoldier->sGridNo].ubTerrainID, Weapon[ usWeaponIndex ].ubHitVolume, NOISE_BULLET_IMPACT ); // CALLAHAN START BUGFIX - if ( EXPLOSIVE_GUN( usWeaponIndex ) || AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ubGunAmmoType].explosionSize > 1) + if ( EXPLOSIVE_GUN( usWeaponIndex ) || AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].explosionSize > 1) // CALLAHAN END BUGFIX { // Reduce attacker count! //TODO: Madd --- I don't think this code will ever get called for the HE ammo -- the EXPLOSIVE_GUN check filters out regular guns // marke test mag ammo type: pSoldier->inv[pSoldier->ubAttackingHand ].ubGunAmmoType // 2cond 'or' added - if ( Item[usWeaponIndex].rocketlauncher || AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ubGunAmmoType].explosionSize > 1 ) + if ( Item[usWeaponIndex].rocketlauncher || AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].explosionSize > 1 ) { if ( Item[usWeaponIndex].singleshotrocketlauncher ) { @@ -2956,13 +2956,13 @@ void WeaponHit( UINT16 usSoldierID, UINT16 usWeaponIndex, INT16 sDamage, INT16 s { DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("WeaponHit: RPG7 item: %d, Ammo: %d",pSoldier->inv[HANDPOS].usItem , pSoldier->inv[HANDPOS].usGunAmmoItem ) ); - IgniteExplosion( ubAttackerID, sXPos, sYPos, 0, (INT16) (GETWORLDINDEXFROMWORLDCOORDS( sYPos, sXPos )), pSoldier->inv[pSoldier->ubAttackingHand ].usGunAmmoItem, pTargetSoldier->bLevel ); - pSoldier->inv[pSoldier->ubAttackingHand ].usGunAmmoItem = NONE; + IgniteExplosion( ubAttackerID, sXPos, sYPos, 0, (INT16) (GETWORLDINDEXFROMWORLDCOORDS( sYPos, sXPos )), pSoldier->inv[pSoldier->ubAttackingHand ].ItemData.Gun.usGunAmmoItem, pTargetSoldier->bLevel ); + pSoldier->inv[pSoldier->ubAttackingHand ].ItemData.Gun.usGunAmmoItem = NONE; } - else if ( AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ubGunAmmoType].explosionSize > 1) + else if ( AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].explosionSize > 1) { // re-routed the Highexplosive value to define exposion type - IgniteExplosion( ubAttackerID, sXPos, sYPos, 0, (INT16) (GETWORLDINDEXFROMWORLDCOORDS( sYPos, sXPos )), AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ubGunAmmoType].highExplosive , pTargetSoldier->bLevel ); + IgniteExplosion( ubAttackerID, sXPos, sYPos, 0, (INT16) (GETWORLDINDEXFROMWORLDCOORDS( sYPos, sXPos )), AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].highExplosive , pTargetSoldier->bLevel ); // pSoldier->inv[pSoldier->ubAttackingHand ].usGunAmmoItem = NONE; } } @@ -3064,7 +3064,7 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT8 bWeaponStatus, UINT // Get attacker pSoldier = MercPtrs[ ubAttackerID ]; // marke added one 'or' to get this working with HE ammo - if ( Item[usWeaponIndex].rocketlauncher || AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ubGunAmmoType].explosionSize > 1) + if ( Item[usWeaponIndex].rocketlauncher || AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].explosionSize > 1) { // Reduce attacker count! DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("@@@@@@@ Freeing up attacker - end of LAW fire") ); @@ -3077,13 +3077,13 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT8 bWeaponStatus, UINT else if ( !Item[usWeaponIndex].singleshotrocketlauncher && Item[usWeaponIndex].rocketlauncher) { DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("StructureHit: RPG7 item: %d, Ammo: %d",pAttacker->inv[HANDPOS].usItem , pAttacker->inv[HANDPOS].usGunAmmoItem ) ); - IgniteExplosion( ubAttackerID, (INT16)CenterX( sGridNo ), (INT16)CenterY( sGridNo ), 0, sGridNo, pAttacker->inv[pAttacker->ubAttackingHand ].usGunAmmoItem , (INT8)( sZPos >= WALL_HEIGHT ) ); - pAttacker->inv[pAttacker->ubAttackingHand ].usGunAmmoItem = NONE; + IgniteExplosion( ubAttackerID, (INT16)CenterX( sGridNo ), (INT16)CenterY( sGridNo ), 0, sGridNo, pAttacker->inv[pAttacker->ubAttackingHand ].ItemData.Gun.usGunAmmoItem , (INT8)( sZPos >= WALL_HEIGHT ) ); + pAttacker->inv[pAttacker->ubAttackingHand ].ItemData.Gun.usGunAmmoItem = NONE; } - else if ( AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ubGunAmmoType].explosionSize > 1) + else if ( AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].explosionSize > 1) { // re-routed the Highexplosive value to define exposion type - IgniteExplosion( ubAttackerID, (INT16)CenterX( sGridNo ), (INT16)CenterY( sGridNo ), 0, sGridNo, AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ubGunAmmoType].highExplosive , (INT8)( sZPos >= WALL_HEIGHT ) ); + IgniteExplosion( ubAttackerID, (INT16)CenterX( sGridNo ), (INT16)CenterY( sGridNo ), 0, sGridNo, AmmoTypes[pSoldier->inv[pSoldier->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].highExplosive , (INT8)( sZPos >= WALL_HEIGHT ) ); // pSoldier->inv[pSoldier->ubAttackingHand ].usGunAmmoItem = NONE; } @@ -3492,7 +3492,7 @@ UINT32 CalcChanceToHitGun(SOLDIERTYPE *pSoldier, UINT16 sGridNo, UINT8 ubAimTime usInHand = pSoldier->usAttackingWeapon; // DETERMINE BASE CHANCE OF HITTING - iGunCondition = WEAPON_STATUS_MOD( pInHand->bGunStatus ); + iGunCondition = WEAPON_STATUS_MOD( pInHand->ItemData.Gun.bGunStatus ); if (Item[usInHand].rocketlauncher ) { @@ -4309,8 +4309,8 @@ INT32 TotalArmourProtection( SOLDIERTYPE *pFirer, SOLDIERTYPE * pTarget, UINT8 u // if the plate didn't stop the bullet... if ( iImpact > iTotalProtection ) { - iTotalProtection += ArmourProtection( pTarget, Item[pArmour->usItem].ubClassIndex, &(pArmour->bStatus[0]), iImpact, ubAmmoType, &plateHit ); - if ( pArmour->bStatus[ 0 ] < USABLE ) + iTotalProtection += ArmourProtection( pTarget, Item[pArmour->usItem].ubClassIndex, &(pArmour->ItemData.Generic.bStatus[0]), iImpact, ubAmmoType, &plateHit ); + if ( pArmour->ItemData.Generic.bStatus[ 0 ] < USABLE ) { //Madd: put any attachments that someone might have added to the armour in the merc's inventory for (int bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) @@ -4348,7 +4348,7 @@ INT32 BulletImpact( SOLDIERTYPE *pFirer, SOLDIERTYPE * pTarget, UINT8 ubHitLocat } else { - ubAmmoType = pFirer->inv[pFirer->ubAttackingHand].ubGunAmmoType; + ubAmmoType = pFirer->inv[pFirer->ubAttackingHand].ItemData.Gun.ubGunAmmoType; } if ( TANK( pTarget ) ) @@ -5198,7 +5198,7 @@ void ReloadWeapon( SOLDIERTYPE *pSoldier, UINT8 ubHandPos ) if ( pSoldier->inv[ ubHandPos ].usItem != NOTHING ) { - pSoldier->inv[ ubHandPos ].ubGunShotsLeft = GetMagSize(&pSoldier->inv[ ubHandPos ]); + pSoldier->inv[ ubHandPos ].ItemData.Gun.ubGunShotsLeft = GetMagSize(&pSoldier->inv[ ubHandPos ]); // Dirty Bars DirtyMercPanelInterface( pSoldier, DIRTYLEVEL1 ); } @@ -5536,7 +5536,7 @@ UINT32 CalcThrownChanceToHit(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAimTi // if iChance exists, but it's a mechanical item being used if ((iChance > 0) && (Item[ usHandItem ].usItemClass == IC_LAUNCHER )) // reduce iChance to hit DIRECTLY by the item's working condition - iChance = (iChance * WEAPON_STATUS_MOD(pSoldier->inv[HANDPOS].bStatus[0])) / 100; + iChance = (iChance * WEAPON_STATUS_MOD(pSoldier->inv[HANDPOS].ItemData.Generic.bStatus[0])) / 100; // MAKE SURE CHANCE TO HIT IS WITHIN DEFINED LIMITS if (iChance < MINCHANCETOHIT) @@ -5659,7 +5659,7 @@ BOOLEAN WillExplosiveWeaponFail( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObj ) { if ( pSoldier->bTeam == gbPlayerNum || pSoldier->bVisible == 1 ) { - if ( (INT8)(PreRandom( 40 ) + PreRandom( 40 ) ) > pObj->bStatus[0] ) + if ( (INT8)(PreRandom( 40 ) + PreRandom( 40 ) ) > pObj->ItemData.Generic.bStatus[0] ) { // Do second dice roll if ( PreRandom( 2 ) == 1 ) diff --git a/Tactical/World Items.cpp b/Tactical/World Items.cpp index a9207c7e..3957b683 100644 --- a/Tactical/World Items.cpp +++ b/Tactical/World Items.cpp @@ -162,12 +162,12 @@ void FindPanicBombsAndTriggers( void ) if (gWorldBombs[ uiBombIndex ].fExists) { pObj = &(gWorldItems[ gWorldBombs[ uiBombIndex ].iItemIndex ].o); - if (pObj->bFrequency == PANIC_FREQUENCY || pObj->bFrequency == PANIC_FREQUENCY_2 || pObj->bFrequency == PANIC_FREQUENCY_3 ) + if (pObj->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY || pObj->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY_2 || pObj->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY_3 ) { if (pObj->usItem == SWITCH) { sGridNo = gWorldItems[ gWorldBombs[ uiBombIndex ].iItemIndex ].sGridNo; - switch( pObj->bFrequency ) + switch( pObj->ItemData.Trigger.BombTrigger.bFrequency ) { case PANIC_FREQUENCY: bPanicIndex = 0; @@ -205,7 +205,7 @@ void FindPanicBombsAndTriggers( void ) } gTacticalStatus.sPanicTriggerGridNo[ bPanicIndex ] = sGridNo; - gTacticalStatus.ubPanicTolerance[ bPanicIndex ] = pObj->ubTolerance; + gTacticalStatus.ubPanicTolerance[ bPanicIndex ] = pObj->ItemData.Trigger.Area.ubTolerance; if (pObj->fFlags & OBJECT_ALARM_TRIGGER) { gTacticalStatus.bPanicTriggerIsAlarm[ bPanicIndex ] = TRUE; @@ -466,11 +466,11 @@ void LoadWorldItemsFromMap( INT8 **hBuffer ) } if( dummyItem.o.usItem == ACTION_ITEM && gfLoadPitsWithoutArming ) { //if we are loading a pit, they are typically loaded without being armed. - if( dummyItem.o.bActionValue == ACTION_ITEM_SMALL_PIT || dummyItem.o.bActionValue == ACTION_ITEM_LARGE_PIT ) + if( dummyItem.o.ItemData.Trigger.bActionValue == ACTION_ITEM_SMALL_PIT || dummyItem.o.ItemData.Trigger.bActionValue == ACTION_ITEM_LARGE_PIT ) { dummyItem.usFlags &= ~WORLD_ITEM_ARMED_BOMB; dummyItem.bVisible = BURIED; - dummyItem.o.bDetonatorType = 0; + dummyItem.o.ItemData.Trigger.bDetonatorType = 0; } } @@ -519,11 +519,11 @@ void DeleteWorldItemsBelongingToTerroristsWhoAreNotThere( void ) if ( gWorldItems[ uiLoop ].fExists && gWorldItems[ uiLoop ].o.usItem == OWNERSHIP ) { // if owner is a terrorist - if ( IsProfileATerrorist( gWorldItems[ uiLoop ].o.ubOwnerProfile ) ) + if ( IsProfileATerrorist( gWorldItems[ uiLoop ].o.ItemData.Owner.ubOwnerProfile ) ) { // and they were not set in the current sector - if ( gMercProfiles[ gWorldItems[ uiLoop ].o.ubOwnerProfile ].sSectorX != gWorldSectorX || - gMercProfiles[ gWorldItems[ uiLoop ].o.ubOwnerProfile ].sSectorY != gWorldSectorY ) + if ( gMercProfiles[ gWorldItems[ uiLoop ].o.ItemData.Owner.ubOwnerProfile ].sSectorX != gWorldSectorX || + gMercProfiles[ gWorldItems[ uiLoop ].o.ItemData.Owner.ubOwnerProfile ].sSectorY != gWorldSectorY ) { // then all items in this location should be deleted sGridNo = gWorldItems[ uiLoop ].sGridNo; @@ -563,7 +563,7 @@ void DeleteWorldItemsBelongingToQueenIfThere( void ) if ( gWorldItems[ uiLoop ].fExists && gWorldItems[ uiLoop ].o.usItem == OWNERSHIP ) { // if owner is the Queen - if ( gWorldItems[ uiLoop ].o.ubOwnerProfile == QUEEN ) + if ( gWorldItems[ uiLoop ].o.ItemData.Owner.ubOwnerProfile == QUEEN ) { // then all items in this location should be deleted sGridNo = gWorldItems[ uiLoop ].sGridNo; diff --git a/Tactical/bullets.cpp b/Tactical/bullets.cpp index 3faa80ac..f003c7bb 100644 --- a/Tactical/bullets.cpp +++ b/Tactical/bullets.cpp @@ -142,7 +142,7 @@ void HandleBulletSpecialFlags( INT32 iBulletIndex ) else if ( pBullet->usFlags & ( BULLET_FLAG_KNIFE ) ) { strcpy( AniParams.zCachedFile, "TILECACHE\\KNIFING.STI" ); - pBullet->ubItemStatus = pBullet->pFirer->inv[ HANDPOS ].bStatus[0]; + pBullet->ubItemStatus = pBullet->pFirer->inv[ HANDPOS ].ItemData.Generic.bStatus[0]; } // Get direction to use for this guy.... diff --git a/Tactical/opplist.cpp b/Tactical/opplist.cpp index 609ee48e..11d14c83 100644 --- a/Tactical/opplist.cpp +++ b/Tactical/opplist.cpp @@ -4392,36 +4392,36 @@ void WriteQuantityAndAttachments( OBJECTTYPE *pObject, INT32 yp ) CHAR16 str[50]; CHAR16 temp[5]; UINT8 i; - swprintf( str, L"Clips: %d (%d", pObject->ubNumberOfObjects, pObject->bStatus[0] ); + swprintf( str, L"Clips: %d (%d", pObject->ubNumberOfObjects, pObject->ItemData.Generic.bStatus[0] ); for( i = 1; i < pObject->ubNumberOfObjects; i++ ) { - swprintf( temp, L", %d", pObject->bStatus[0] ); + swprintf( temp, L", %d", pObject->ItemData.Generic.bStatus[0] ); wcscat( str, temp ); } wcscat( str, L")" ); gprintf( 320, yp, str ); } else - gprintf( 320, yp, L"%d rounds", pObject->bStatus[0] ); + gprintf( 320, yp, L"%d rounds", pObject->ItemData.Generic.bStatus[0] ); return; } if( pObject->ubNumberOfObjects > 1 && fAttachments ) { //everything gprintf( 320, yp, L"%d%% Qty: %d %s", - pObject->bStatus[0], pObject->ubNumberOfObjects, szAttach ); + pObject->ItemData.Generic.bStatus[0], pObject->ubNumberOfObjects, szAttach ); } else if( pObject->ubNumberOfObjects > 1 ) { //condition and quantity gprintf( 320, yp, L"%d%% Qty: %d ", - pObject->bStatus[0], pObject->ubNumberOfObjects ); + pObject->ItemData.Generic.bStatus[0], pObject->ubNumberOfObjects ); } else if( fAttachments ) { //condition and attachments - gprintf( 320, yp, L"%d%% %s", pObject->bStatus[0], szAttach ); + gprintf( 320, yp, L"%d%% %s", pObject->ItemData.Generic.bStatus[0], szAttach ); } else { //condition - gprintf( 320, yp, L"%d%%", pObject->bStatus[0] ); + gprintf( 320, yp, L"%d%%", pObject->ItemData.Generic.bStatus[0] ); } } diff --git a/TacticalAI/AIUtils.cpp b/TacticalAI/AIUtils.cpp index a8b8e0f1..159eac8e 100644 --- a/TacticalAI/AIUtils.cpp +++ b/TacticalAI/AIUtils.cpp @@ -101,7 +101,7 @@ INT8 OKToAttack(SOLDIERTYPE * pSoldier, int target) return(NOSHOOT_NOLOAD); } } - else if (pSoldier->inv[HANDPOS].ubGunShotsLeft == 0 /*SB*/ || !(pSoldier->inv[HANDPOS].ubGunState & GS_CARTRIDGE_IN_CHAMBER)) + else if (pSoldier->inv[HANDPOS].ItemData.Gun.ubGunShotsLeft == 0 /*SB*/ || !(pSoldier->inv[HANDPOS].ItemData.Gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER)) { return(NOSHOOT_NOAMMO); } @@ -1354,7 +1354,7 @@ INT16 FindClosestClimbPointAvailableToAI( SOLDIERTYPE * pSoldier, INT16 sStartGr // since climbing necessary involves going an extra tile, we compare against 1 less than the roam range... // or add 1 to the distance to the climb point - sGridNo = FindClosestClimbPoint( sStartGridNo, sDesiredGridNo, fClimbUp ); + sGridNo = FindClosestClimbPoint( pSoldier, sStartGridNo, sDesiredGridNo, fClimbUp ); if ( PythSpacesAway( sRoamingOrigin, sGridNo ) + 1 > sRoamingRange ) diff --git a/TacticalAI/Attacks.cpp b/TacticalAI/Attacks.cpp index 753bda67..ee59e76c 100644 --- a/TacticalAI/Attacks.cpp +++ b/TacticalAI/Attacks.cpp @@ -102,7 +102,7 @@ void LoadWeaponIfNeeded(SOLDIERTYPE *pSoldier) // remove payload from its pocket, and add it as the hand weapon's first attachment OBJECTTYPE Temp; - CreateItem(pSoldier->inv[bPayloadPocket].usItem,pSoldier->inv[bPayloadPocket].bStatus[0],&Temp); + CreateItem(pSoldier->inv[bPayloadPocket].usItem,pSoldier->inv[bPayloadPocket].ItemData.Generic.bStatus[0],&Temp); AttachObject ( pSoldier, &pSoldier->inv[HANDPOS],&Temp,FALSE); //pSoldier->inv[HANDPOS].usAttachItem[0] = pSoldier->inv[bPayloadPocket].usItem; @@ -1590,7 +1590,7 @@ INT32 EstimateShotDamage(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, UINT8 ub } else { - ubAmmoType = pSoldier->inv[pSoldier->ubAttackingHand].ubGunAmmoType; + ubAmmoType = pSoldier->inv[pSoldier->ubAttackingHand].ItemData.Gun.ubGunAmmoType; } // calculate distance to target, obtain his gun's maximum range rating @@ -1612,7 +1612,7 @@ INT32 EstimateShotDamage(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, UINT8 ub if (pOpponent->inv[HELMETPOS].usItem) { iHeadProt += (INT32) Armour[Item[pOpponent->inv[HELMETPOS].usItem].ubClassIndex].ubProtection * - (INT32) pOpponent->inv[HELMETPOS].bStatus[0] / 100; + (INT32) pOpponent->inv[HELMETPOS].ItemData.Generic.bStatus[0] / 100; } // if opponent is wearing a protective vest @@ -1622,7 +1622,7 @@ INT32 EstimateShotDamage(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, UINT8 ub if (pOpponent->inv[VESTPOS].usItem) { iTorsoProt += (INT32) Armour[Item[pOpponent->inv[VESTPOS].usItem].ubClassIndex].ubProtection * - (INT32) pOpponent->inv[VESTPOS].bStatus[0] / 100; + (INT32) pOpponent->inv[VESTPOS].ItemData.Generic.bStatus[0] / 100; } } @@ -1641,7 +1641,7 @@ INT32 EstimateShotDamage(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, UINT8 ub if (pOpponent->inv[LEGPOS].usItem) { iLegProt += (INT32) Armour[Item[pOpponent->inv[LEGPOS].usItem].ubClassIndex].ubProtection * - (INT32) pOpponent->inv[LEGPOS].bStatus[0] / 100; + (INT32) pOpponent->inv[LEGPOS].ItemData.Generic.bStatus[0] / 100; } } @@ -1764,7 +1764,7 @@ INT32 EstimateThrowDamage( SOLDIERTYPE *pSoldier, UINT8 ubItemPos, SOLDIERTYPE * if (bSlot == HEAD1POS || bSlot == HEAD2POS) { // take condition of the gas mask into account - it could be leaking - iBreathDamage = (iBreathDamage * (100 - pOpponent->inv[bSlot].bStatus[0])) / 100; + iBreathDamage = (iBreathDamage * (100 - pOpponent->inv[bSlot].ItemData.Generic.bStatus[0])) / 100; //NumMessage("damage after GAS MASK: ",iBreathDamage); } @@ -1803,7 +1803,7 @@ INT32 EstimateThrowDamage( SOLDIERTYPE *pSoldier, UINT8 ubItemPos, SOLDIERTYPE * // approximate chance of the grenade going off (Ian's formulas are too funky) // then use that to reduce the expected damage because thing may not blow! - iDamage = (iDamage * pSoldier->inv[ubItemPos].bStatus[0]) / 100; + iDamage = (iDamage * pSoldier->inv[ubItemPos].ItemData.Generic.bStatus[0]) / 100; // if the target gridno is in water, grenade may not blow (guess 50% of time) /* @@ -1895,9 +1895,9 @@ INT8 TryToReload( SOLDIERTYPE * pSoldier ) // manual recharge pObj = &(pSoldier->inv[HANDPOS]); - if (pObj->ubGunShotsLeft && !(pObj->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) + if (pObj->ItemData.Gun.ubGunShotsLeft && !(pObj->ItemData.Gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) { - pObj->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; + pObj->ItemData.Gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; DeductPoints(pSoldier, Weapon[Item[(pObj)->usItem].ubClassIndex].APsToReloadManually, 0); @@ -1908,9 +1908,9 @@ INT8 TryToReload( SOLDIERTYPE * pSoldier ) { pObj2 = &(pSoldier->inv[SECONDHANDPOS]); - if (pObj2->ubGunShotsLeft && !(pObj2->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) + if (pObj2->ItemData.Gun.ubGunShotsLeft && !(pObj2->ItemData.Gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) { - pObj2->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; + pObj2->ItemData.Gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; PlayJA2Sample( Weapon[ Item[pObj2->usItem].ubClassIndex ].ManualReloadSound, RATE_11025, SoundVolume( HIGHVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ) ); } } @@ -1923,9 +1923,9 @@ INT8 TryToReload( SOLDIERTYPE * pSoldier ) { pObj2 = &(pSoldier->inv[SECONDHANDPOS]); - if (pObj2->ubGunShotsLeft && !(pObj2->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) + if (pObj2->ItemData.Gun.ubGunShotsLeft && !(pObj2->ItemData.Gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) { - pObj2->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; + pObj2->ItemData.Gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; DeductPoints(pSoldier, Weapon[Item[(pObj2)->usItem].ubClassIndex].APsToReloadManually, 0); @@ -2470,7 +2470,7 @@ void CheckIfShotPossible(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestShot, BOOLEAN s } if ( (!suppressionFire && ( (IsScoped(pObj) && GunRange(pObj) > MaxDistanceVisible() ) || pSoldier->bOrders == SNIPER ) ) || - (suppressionFire && IsGunAutofireCapable(pSoldier,pBestShot->bWeaponIn ) && GetMagSize(pObj) > 30 && pObj->ubGunShotsLeft > 20 )) + (suppressionFire && IsGunAutofireCapable(pSoldier,pBestShot->bWeaponIn ) && GetMagSize(pObj) > 30 && pObj->ItemData.Gun.ubGunShotsLeft > 20 )) { // get the minimum cost to attack with this item DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"CheckIfShotPossible: getting min aps"); diff --git a/TacticalAI/CreatureDecideAction.cpp b/TacticalAI/CreatureDecideAction.cpp index 4fd9bc93..ec435347 100644 --- a/TacticalAI/CreatureDecideAction.cpp +++ b/TacticalAI/CreatureDecideAction.cpp @@ -1117,9 +1117,9 @@ INT8 CreatureDecideActionBlack( SOLDIERTYPE * pSoldier ) if (bWeaponIn != NO_SLOT) { - if (Item[pSoldier->inv[bWeaponIn].usItem].usItemClass == IC_GUN && pSoldier->inv[bWeaponIn].bGunStatus >= USABLE) + if (Item[pSoldier->inv[bWeaponIn].usItem].usItemClass == IC_GUN && pSoldier->inv[bWeaponIn].ItemData.Gun.bGunStatus >= USABLE) { - if (pSoldier->inv[bWeaponIn].ubGunShotsLeft > 0) + if (pSoldier->inv[bWeaponIn].ItemData.Gun.ubGunShotsLeft > 0) { bSpitIn = bWeaponIn; // if it's in another pocket, swap it into his hand temporarily diff --git a/TacticalAI/DecideAction.cpp b/TacticalAI/DecideAction.cpp index 103788dc..90df3f50 100644 --- a/TacticalAI/DecideAction.cpp +++ b/TacticalAI/DecideAction.cpp @@ -984,7 +984,7 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier) pSoldier->usActionData = FindClosestClimbPoint(pSoldier, fUp ); // Added the check here because sniper militia who are locked inside of a building without keys // will still have a >100% chance to want to climb, which means an infinite loop. In fact, any - // time a move is desired, there is also probably be a need to check for a path. + // time a move is desired, there probably also will be a need to check for a path. if ( pSoldier->usActionData != NOWHERE && LegalNPCDestination(pSoldier,pSoldier->usActionData,ENSURE_PATH,WATEROK, 0 )) { @@ -1525,8 +1525,11 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier) return AI_ACTION_SEEK_NOISE ; } - - if ( !( pSoldier->bTeam == CIV_TEAM && pSoldier->ubProfile != NO_PROFILE && pSoldier->ubProfile != ELDIN ) ) + // Hmmm, I don't think this check is doing what is intended. But then I see no comment about what is intended. + // However, civilians with no profile (and likely no weapons) do not need to be seeking out noises. Most don't + // even have the body type for it (can't climb or jump). + //if ( !( pSoldier->bTeam == CIV_TEAM && pSoldier->ubProfile != NO_PROFILE && pSoldier->ubProfile != ELDIN ) ) + if ( pSoldier->bTeam != CIV_TEAM || ( pSoldier->ubProfile != NO_PROFILE && pSoldier->ubProfile != ELDIN ) ) { // IF WE ARE MILITIA/CIV IN REALTIME, CLOSE TO NOISE, AND CAN SEE THE SPOT WHERE THE NOISE CAME FROM, FORGET IT if ( fReachable && !fClimb && !gfTurnBasedAI && (pSoldier->bTeam == MILITIA_TEAM || pSoldier->bTeam == CIV_TEAM )&& PythSpacesAway( pSoldier->sGridNo, sNoiseGridNo ) < 5 ) @@ -1619,7 +1622,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier) } else { - pSoldier->usActionData = FindClosestClimbPoint(pSoldier->sGridNo , sNoiseGridNo , fUp ); + pSoldier->usActionData = FindClosestClimbPoint(pSoldier, pSoldier->sGridNo , sNoiseGridNo , fUp ); if ( pSoldier->usActionData != NOWHERE ) { return( AI_ACTION_MOVE_TO_CLIMB ); @@ -1759,7 +1762,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier) } else { - pSoldier->usActionData = FindClosestClimbPoint(pSoldier->sGridNo , sClosestFriend , fUp ); + pSoldier->usActionData = FindClosestClimbPoint(pSoldier, pSoldier->sGridNo , sClosestFriend , fUp ); if ( pSoldier->usActionData != NOWHERE ) { return( AI_ACTION_MOVE_TO_CLIMB ); @@ -2293,7 +2296,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK) ubBurstAPs = CalcAPsToAutofire( CalcActionPoints( pSoldier ), &(pSoldier->inv[BestShot.bWeaponIn]), pSoldier->bDoAutofire ); } while( pSoldier->bActionPoints >= BestShot.ubAPCost + ubBurstAPs && - pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft >= pSoldier->bDoAutofire && + pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft >= pSoldier->bDoAutofire && GetAutoPenalty(&pSoldier->inv[ pSoldier->ubAttackingHand ], gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_PRONE)*pSoldier->bDoAutofire <= 80 ); @@ -2779,7 +2782,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK) } else { - pSoldier->usActionData = FindClosestClimbPoint(pSoldier->sGridNo , sClosestDisturbance , fUp ); + pSoldier->usActionData = FindClosestClimbPoint(pSoldier, pSoldier->sGridNo , sClosestDisturbance , fUp ); if ( pSoldier->usActionData != NOWHERE ) { return( AI_ACTION_MOVE_TO_CLIMB ); @@ -2993,7 +2996,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK) } else { - pSoldier->usActionData = FindClosestClimbPoint(pSoldier->sGridNo , sClosestFriend , fUp ); + pSoldier->usActionData = FindClosestClimbPoint(pSoldier, pSoldier->sGridNo , sClosestFriend , fUp ); if ( pSoldier->usActionData != NOWHERE ) { return( AI_ACTION_MOVE_TO_CLIMB ); @@ -3796,7 +3799,7 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier) } // now it better be a gun, or the guy can't shoot (but has other attack(s)) - if (Item[pSoldier->inv[HANDPOS].usItem].usItemClass == IC_GUN && pSoldier->inv[HANDPOS].bGunStatus >= USABLE) + if (Item[pSoldier->inv[HANDPOS].usItem].usItemClass == IC_GUN && pSoldier->inv[HANDPOS].ItemData.Gun.bGunStatus >= USABLE) { // get the minimum cost to attack the same target with this gun ubMinAPCost = MinAPsToAttack(pSoldier,pSoldier->sLastTarget,ADDTURNCOST); @@ -4319,7 +4322,7 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier) if (IsGunBurstCapable( pSoldier, BestAttack.bWeaponIn, FALSE ) && !(Menptr[BestShot.ubOpponent].bLife < OKLIFE) && // don't burst at downed targets - pSoldier->inv[BestAttack.bWeaponIn].ubGunShotsLeft > 1 && + pSoldier->inv[BestAttack.bWeaponIn].ItemData.Gun.ubGunShotsLeft > 1 && (pSoldier->bTeam != gbPlayerNum || pSoldier->bRTPCombat == RTP_COMBAT_AGGRESSIVE) ) { DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"DecideActionBlack: ENOUGH APs TO BURST, RANDOM CHANCE OF DOING SO"); @@ -4347,7 +4350,7 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier) case ATTACKSLAYONLY:iChance += 30; break; } - if ( pSoldier->inv[BestAttack.bWeaponIn].ubGunShotsLeft > 50 ) + if ( pSoldier->inv[BestAttack.bWeaponIn].ItemData.Gun.ubGunShotsLeft > 50 ) iChance += 20; // increase chance based on proximity and difficulty of enemy @@ -4382,7 +4385,7 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier) if (IsGunAutofireCapable( pSoldier, BestAttack.bWeaponIn ) && !(Menptr[BestShot.ubOpponent].bLife < OKLIFE) && // don't burst at downed targets - (( pSoldier->inv[BestAttack.bWeaponIn].ubGunShotsLeft > 1 && + (( pSoldier->inv[BestAttack.bWeaponIn].ItemData.Gun.ubGunShotsLeft > 1 && BestAttack.ubAimTime != BURSTING ) || Weapon[pSoldier->inv[BestAttack.bWeaponIn].usItem].NoSemiAuto) ) { DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"DecideActionBlack: ENOUGH APs TO AUTOFIRE, RANDOM CHANCE OF DOING SO"); @@ -4393,7 +4396,7 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier) ubBurstAPs = CalcAPsToAutofire( CalcActionPoints( pSoldier ), &(pSoldier->inv[BestAttack.bWeaponIn]), pSoldier->bDoAutofire ); } while( pSoldier->bActionPoints >= BestAttack.ubAPCost + ubBurstAPs && - pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunShotsLeft >= pSoldier->bDoAutofire && + pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft >= pSoldier->bDoAutofire && GetAutoPenalty(&pSoldier->inv[ BestAttack.bWeaponIn ], gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_PRONE)*pSoldier->bDoAutofire <= 80); @@ -4425,7 +4428,7 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier) } - if ( pSoldier->inv[BestAttack.bWeaponIn].ubGunShotsLeft > 50 ) + if ( pSoldier->inv[BestAttack.bWeaponIn].ItemData.Gun.ubGunShotsLeft > 50 ) iChance += 30; if ( bInGas ) diff --git a/TacticalAI/FindLocations.cpp b/TacticalAI/FindLocations.cpp index 4a6a808d..575816c4 100644 --- a/TacticalAI/FindLocations.cpp +++ b/TacticalAI/FindLocations.cpp @@ -1769,16 +1769,16 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem ) { pObj = &(gWorldItems[ pItemPool->iItemIndex ].o); pItem = &(Item[pObj->usItem]); - if ( pItem->usItemClass == IC_GUN && pObj->bStatus[0] >= MINIMUM_REQUIRED_STATUS ) + if ( pItem->usItemClass == IC_GUN && pObj->ItemData.Generic.bStatus[0] >= MINIMUM_REQUIRED_STATUS ) { // maybe this gun has ammo (adjust for whether it is better than ours!) - if ( pObj->bGunAmmoStatus < 0 || pObj->ubGunShotsLeft == 0 || (Item[pObj->usItem].fingerprintid && pObj->ubImprintID != NOBODY && pObj->ubImprintID != pSoldier->ubID) ) + if ( pObj->ItemData.Gun.bGunAmmoStatus < 0 || pObj->ItemData.Gun.ubGunShotsLeft == 0 || (Item[pObj->usItem].fingerprintid && pObj->ubImprintID != NOBODY && pObj->ubImprintID != pSoldier->ubID) ) { iTempValue = 0; } else { - iTempValue = pObj->ubGunShotsLeft * Weapon[pObj->usItem].ubDeadliness / Weapon[usItem].ubDeadliness; + iTempValue = pObj->ItemData.Gun.ubGunShotsLeft * Weapon[pObj->usItem].ubDeadliness / Weapon[usItem].ubDeadliness; } } else if (ValidAmmoType( usItem, pObj->usItem ) ) @@ -1802,9 +1802,9 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem ) { pObj = &(gWorldItems[ pItemPool->iItemIndex ].o); pItem = &(Item[pObj->usItem]); - if (pItem->usItemClass & IC_WEAPON && pObj->bStatus[0] >= MINIMUM_REQUIRED_STATUS ) + if (pItem->usItemClass & IC_WEAPON && pObj->ItemData.Generic.bStatus[0] >= MINIMUM_REQUIRED_STATUS ) { - if ( (pItem->usItemClass & IC_GUN) && (pObj->bGunAmmoStatus < 0 || pObj->ubGunShotsLeft == 0 || (( Item[pObj->usItem].fingerprintid ) && pObj->ubImprintID != NOBODY && pObj->ubImprintID != pSoldier->ubID) ) ) + if ( (pItem->usItemClass & IC_GUN) && (pObj->ItemData.Gun.bGunAmmoStatus < 0 || pObj->ItemData.Gun.ubGunShotsLeft == 0 || (( Item[pObj->usItem].fingerprintid ) && pObj->ubImprintID != NOBODY && pObj->ubImprintID != pSoldier->ubID) ) ) { // jammed or out of ammo, skip it! iTempValue = 0; @@ -1842,9 +1842,9 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem ) { pObj = &(gWorldItems[ pItemPool->iItemIndex ].o); pItem = &(Item[pObj->usItem]); - if ( pItem->usItemClass & IC_WEAPON && pObj->bStatus[0] >= MINIMUM_REQUIRED_STATUS ) + if ( pItem->usItemClass & IC_WEAPON && pObj->ItemData.Generic.bStatus[0] >= MINIMUM_REQUIRED_STATUS ) { - if ( (pItem->usItemClass & IC_GUN) && (pObj->bGunAmmoStatus < 0 || pObj->ubGunShotsLeft == 0 || (( Item[pObj->usItem].fingerprintid ) && pObj->ubImprintID != NOBODY && pObj->ubImprintID != pSoldier->ubID) ) ) + if ( (pItem->usItemClass & IC_GUN) && (pObj->ItemData.Gun.bGunAmmoStatus < 0 || pObj->ItemData.Gun.ubGunShotsLeft == 0 || (( Item[pObj->usItem].fingerprintid ) && pObj->ubImprintID != NOBODY && pObj->ubImprintID != pSoldier->ubID) ) ) { // jammed or out of ammo, skip it! iTempValue = 0; @@ -1865,7 +1865,7 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem ) iTempValue = 200 + Weapon[pObj->usItem].ubDeadliness; } } - else if (pItem->usItemClass == IC_ARMOUR && pObj->bStatus[0] >= MINIMUM_REQUIRED_STATUS ) + else if (pItem->usItemClass == IC_ARMOUR && pObj->ItemData.Generic.bStatus[0] >= MINIMUM_REQUIRED_STATUS ) { switch( Armour[pItem->ubClassIndex].ubArmourClass ) { @@ -2623,7 +2623,7 @@ INT16 FindClosestClimbPoint (SOLDIERTYPE *pSoldier, BOOLEAN fClimbUp ) if ( FindBuilding ( sGridNo ) != NULL ) { // DebugMsg( TOPIC_JA2AI , DBG_LEVEL_3 , String("Building found at %d", sGridNo )); - sClimbGridNo = FindClosestClimbPoint( pSoldier->sGridNo, sGridNo, fClimbUp); + sClimbGridNo = FindClosestClimbPoint( pSoldier, pSoldier->sGridNo, sGridNo, fClimbUp); // DebugMsg( TOPIC_JA2AI , DBG_LEVEL_3 , String("Closest climb point is %d" , sClimbGridNo )); if ( sClimbGridNo != NOWHERE ) diff --git a/TacticalAI/NPC.cpp b/TacticalAI/NPC.cpp index adaa012e..61ee507c 100644 --- a/TacticalAI/NPC.cpp +++ b/TacticalAI/NPC.cpp @@ -823,7 +823,7 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * case MONEY: case SILVER: case GOLD: - if (pObj->uiMoneyAmount < LARGE_AMOUNT_MONEY) + if (pObj->ItemData.Money.uiMoneyAmount < LARGE_AMOUNT_MONEY) { SetFactTrue( FACT_SMALL_AMOUNT_OF_MONEY ); } @@ -841,7 +841,7 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * break; } - if (pObj->bStatus[0] < 50) + if (pObj->ItemData.Generic.bStatus[0] < 50) { SetFactTrue( FACT_ITEM_POOR_CONDITION ); } @@ -865,14 +865,14 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * case DARREN: if (usItemToConsider == MONEY && pNPCQuoteInfo->sActionData == NPC_ACTION_DARREN_GIVEN_CASH) { - if (pObj->uiMoneyAmount < 1000) + if (pObj->ItemData.Money.uiMoneyAmount < 1000) { // refuse, bet too low - record 15 (*ppResultQuoteInfo) = &pNPCQuoteInfoArray[15]; (*pubQuoteNum) = 15; return( (*ppResultQuoteInfo)->ubOpinionRequired ); } - else if (pObj->uiMoneyAmount > 5000) + else if (pObj->ItemData.Money.uiMoneyAmount > 5000) { // refuse, bet too high - record 16 (*ppResultQuoteInfo) = &pNPCQuoteInfoArray[16]; @@ -896,7 +896,7 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * */ // record amount of bet - gMercProfiles[ DARREN ].iBalance = pObj->uiMoneyAmount; + gMercProfiles[ DARREN ].iBalance = pObj->ItemData.Money.uiMoneyAmount; SetFactFalse( FACT_DARREN_EXPECTING_MONEY ); // if never fought before, use record 17 @@ -943,14 +943,14 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * case ANGEL: if (usItemToConsider == MONEY && pNPCQuoteInfo->sActionData == NPC_ACTION_ANGEL_GIVEN_CASH) { - if (pObj->uiMoneyAmount < Item[LEATHER_JACKET_W_KEVLAR].usPrice) + if (pObj->ItemData.Money.uiMoneyAmount < Item[LEATHER_JACKET_W_KEVLAR].usPrice) { // refuse, bet too low - record 8 (*ppResultQuoteInfo) = &pNPCQuoteInfoArray[8]; (*pubQuoteNum) = 8; return( (*ppResultQuoteInfo)->ubOpinionRequired ); } - else if (pObj->uiMoneyAmount > Item[LEATHER_JACKET_W_KEVLAR].usPrice) + else if (pObj->ItemData.Money.uiMoneyAmount > Item[LEATHER_JACKET_W_KEVLAR].usPrice) { // refuse, bet too high - record 9 (*ppResultQuoteInfo) = &pNPCQuoteInfoArray[9]; @@ -976,13 +976,13 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * (*pubQuoteNum) = 5; return( (*ppResultQuoteInfo)->ubOpinionRequired ); } - switch( pObj->uiMoneyAmount ) + switch( pObj->ItemData.Money.uiMoneyAmount ) { case 100: case 200: // Carla if ( CheckFact( FACT_CARLA_AVAILABLE, 0 ) ) { - gMercProfiles[ MADAME ].bNPCData += (INT8) (pObj->uiMoneyAmount / 100); + gMercProfiles[ MADAME ].bNPCData += (INT8) (pObj->ItemData.Money.uiMoneyAmount / 100); TriggerNPCRecord( MADAME, 16 ); } else @@ -997,7 +997,7 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * case 1000: // Cindy if ( CheckFact( FACT_CINDY_AVAILABLE, 0 ) ) { - gMercProfiles[ MADAME ].bNPCData += (INT8) (pObj->uiMoneyAmount / 500); + gMercProfiles[ MADAME ].bNPCData += (INT8) (pObj->ItemData.Money.uiMoneyAmount / 500); TriggerNPCRecord( MADAME, 17 ); } else @@ -1012,7 +1012,7 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * case 600: // Bambi if ( CheckFact( FACT_BAMBI_AVAILABLE, 0 ) ) { - gMercProfiles[ MADAME ].bNPCData += (INT8) (pObj->uiMoneyAmount / 300); + gMercProfiles[ MADAME ].bNPCData += (INT8) (pObj->ItemData.Money.uiMoneyAmount / 300); TriggerNPCRecord( MADAME, 18 ); } else @@ -1027,7 +1027,7 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * case 800: // Maria? if ( gubQuest[ QUEST_RESCUE_MARIA ] == QUESTINPROGRESS ) { - gMercProfiles[ MADAME ].bNPCData += (INT8) (pObj->uiMoneyAmount / 400); + gMercProfiles[ MADAME ].bNPCData += (INT8) (pObj->ItemData.Money.uiMoneyAmount / 400); TriggerNPCRecord( MADAME, 19 ); break; } @@ -1072,8 +1072,8 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * if ( CheckFact( FACT_VINCE_EXPECTING_MONEY, ubNPC ) == FALSE && gMercProfiles[ ubNPC ].iBalance < 0 && pNPCQuoteInfo->sActionData != NPC_ACTION_DONT_ACCEPT_ITEM ) { // increment balance - gMercProfiles[ ubNPC ].iBalance += (INT32) pObj->uiMoneyAmount; - gMercProfiles[ ubNPC ].uiTotalCostToDate += pObj->uiMoneyAmount; + gMercProfiles[ ubNPC ].iBalance += (INT32) pObj->ItemData.Money.uiMoneyAmount; + gMercProfiles[ ubNPC ].uiTotalCostToDate += pObj->ItemData.Money.uiMoneyAmount; if ( gMercProfiles[ ubNPC ].iBalance > 0 ) { gMercProfiles[ ubNPC ].iBalance = 0; @@ -1096,7 +1096,7 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * else { // handle the player giving NPC some money - HandleNPCBeingGivenMoneyByPlayer( ubNPC, pObj->uiMoneyAmount, pubQuoteNum ); + HandleNPCBeingGivenMoneyByPlayer( ubNPC, pObj->ItemData.Money.uiMoneyAmount, pubQuoteNum ); (*ppResultQuoteInfo) = &pNPCQuoteInfoArray[ *pubQuoteNum ]; return( (*ppResultQuoteInfo)->ubOpinionRequired ); } @@ -1104,7 +1104,7 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * else { // handle the player giving NPC some money - HandleNPCBeingGivenMoneyByPlayer( ubNPC, pObj->uiMoneyAmount, pubQuoteNum ); + HandleNPCBeingGivenMoneyByPlayer( ubNPC, pObj->ItemData.Money.uiMoneyAmount, pubQuoteNum ); (*ppResultQuoteInfo) = &pNPCQuoteInfoArray[ *pubQuoteNum ]; return( (*ppResultQuoteInfo)->ubOpinionRequired ); } @@ -1113,7 +1113,7 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * case KINGPIN: if ( usItemToConsider == MONEY && gubQuest[ QUEST_KINGPIN_MONEY ] == QUESTINPROGRESS ) { - HandleNPCBeingGivenMoneyByPlayer( ubNPC, pObj->uiMoneyAmount, pubQuoteNum ); + HandleNPCBeingGivenMoneyByPlayer( ubNPC, pObj->ItemData.Money.uiMoneyAmount, pubQuoteNum ); (*ppResultQuoteInfo) = &pNPCQuoteInfoArray[ *pubQuoteNum ]; return( (*ppResultQuoteInfo)->ubOpinionRequired ); } @@ -1124,8 +1124,8 @@ UINT8 NPCConsiderReceivingItemFromMerc( UINT8 ubNPC, UINT8 ubMerc, OBJECTTYPE * if ( gMercProfiles[ ubNPC ].iBalance < 0 && pNPCQuoteInfo->sActionData != NPC_ACTION_DONT_ACCEPT_ITEM ) { // increment balance - gMercProfiles[ ubNPC ].iBalance += (INT32) pObj->uiMoneyAmount; - gMercProfiles[ ubNPC ].uiTotalCostToDate += pObj->uiMoneyAmount; + gMercProfiles[ ubNPC ].iBalance += (INT32) pObj->ItemData.Money.uiMoneyAmount; + gMercProfiles[ ubNPC ].uiTotalCostToDate += pObj->ItemData.Money.uiMoneyAmount; if ( gMercProfiles[ ubNPC ].iBalance > 0 ) { gMercProfiles[ ubNPC ].iBalance = 0; diff --git a/TileEngine/Buildings.cpp b/TileEngine/Buildings.cpp index c1e0d3b2..6bcd6a2a 100644 --- a/TileEngine/Buildings.cpp +++ b/TileEngine/Buildings.cpp @@ -14,6 +14,8 @@ #include "worldman.h" #endif +#include "AIInternals.h" + #define ROOF_LOCATION_CHANCE 8 UINT8 gubBuildingInfo[ WORLD_MAX ]; @@ -440,7 +442,7 @@ void GenerateBuildings( void ) } } -INT16 FindClosestClimbPoint( INT16 sStartGridNo, INT16 sDesiredGridNo, BOOLEAN fClimbUp ) +INT16 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT16 sStartGridNo, INT16 sDesiredGridNo, BOOLEAN fClimbUp ) { BUILDING * pBuilding; UINT8 ubNumClimbSpots; @@ -468,7 +470,8 @@ INT16 FindClosestClimbPoint( INT16 sStartGridNo, INT16 sDesiredGridNo, BOOLEAN f for ( ubLoop = 0; ubLoop < ubNumClimbSpots; ubLoop++ ) { if ( (WhoIsThere2( pBuilding->sUpClimbSpots[ ubLoop ], 0 ) == NOBODY) - && (WhoIsThere2( pBuilding->sDownClimbSpots[ ubLoop ], 1 ) == NOBODY) ) + && (WhoIsThere2( pBuilding->sDownClimbSpots[ ubLoop ], 1 ) == NOBODY) && + (!pSoldier || !InGas( pSoldier, psClimbSpots[ ubLoop] ) ) ) { sDistance = PythSpacesAway( sStartGridNo, psClimbSpots[ ubLoop ] ); if (sDistance < sClosestDistance ) diff --git a/TileEngine/Buildings.h b/TileEngine/Buildings.h index 9b523183..61e7a3c1 100644 --- a/TileEngine/Buildings.h +++ b/TileEngine/Buildings.h @@ -26,7 +26,7 @@ BOOLEAN InBuilding( INT16 sGridNo ); BUILDING * GenerateBuilding( INT16 sDesiredSpot ); BUILDING * FindBuilding( INT16 sGridNo ); void GenerateBuildings( void ); -INT16 FindClosestClimbPoint( INT16 sStartGridNo, INT16 sDesiredGridNo, BOOLEAN fClimbUp ); +INT16 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT16 sStartGridNo, INT16 sDesiredGridNo, BOOLEAN fClimbUp ); BOOLEAN SameBuilding( INT16 sGridNo1, INT16 sGridNo2 ); #endif \ No newline at end of file diff --git a/TileEngine/Explosion Control.cpp b/TileEngine/Explosion Control.cpp index 7b16bdac..ee54039b 100644 --- a/TileEngine/Explosion Control.cpp +++ b/TileEngine/Explosion Control.cpp @@ -247,7 +247,7 @@ void InternalIgniteExplosion( UINT8 ubOwner, INT16 sX, INT16 sY, INT16 sZ, INT16 // Let's check for the attacker first. if ( ubOwner != NOBODY ) { - if ( !( Item[ usItem ].usItemClass & IC_EXPLOSV ) && AmmoTypes[MercPtrs[ubOwner]->inv[MercPtrs[ubOwner]->ubAttackingHand ].ubGunAmmoType].explosionSize < 2 ) + if ( !( Item[ usItem ].usItemClass & IC_EXPLOSV ) && AmmoTypes[MercPtrs[ubOwner]->inv[MercPtrs[ubOwner]->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].explosionSize < 2 ) { return; // no explosive and attackers gun is not fireing HE } @@ -274,7 +274,7 @@ void InternalIgniteExplosion( UINT8 ubOwner, INT16 sX, INT16 sY, INT16 sZ, INT16 // No explosive but an attacker with HE ammo. if ( !( Item[ usItem ].usItemClass & IC_EXPLOSV ) && ubOwner != NOBODY) { - ExpParams.ubTypeID = (INT8)Explosive[AmmoTypes[MercPtrs[ubOwner]->inv[MercPtrs[ubOwner]->ubAttackingHand ].ubGunAmmoType].highExplosive].ubAnimationID; + ExpParams.ubTypeID = (INT8)Explosive[AmmoTypes[MercPtrs[ubOwner]->inv[MercPtrs[ubOwner]->ubAttackingHand ].ItemData.Gun.ubGunAmmoType].highExplosive].ubAnimationID; // return; } else // just normal explosives should get here @@ -1484,7 +1484,7 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN } bPosOfMask = FindGasMask(pSoldier); - if ( bPosOfMask == NO_SLOT || pSoldier->inv[ bPosOfMask ].bStatus[0] < USABLE ) + if ( bPosOfMask == NO_SLOT || pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] < USABLE ) { bPosOfMask = NO_SLOT; } @@ -1499,10 +1499,10 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN if ( bPosOfMask != NO_SLOT ) { - if ( pSoldier->inv[ bPosOfMask ].bStatus[0] < GASMASK_MIN_STATUS ) + if ( pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] < GASMASK_MIN_STATUS ) { // GAS MASK reduces breath loss by its work% (it leaks if not at least 70%) - sBreathAmt = ( sBreathAmt * ( 100 - pSoldier->inv[ bPosOfMask ].bStatus[0] ) ) / 100; + sBreathAmt = ( sBreathAmt * ( 100 - pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] ) ) / 100; if ( sBreathAmt > 500 ) { // if at least 500 of breath damage got through @@ -1516,12 +1516,12 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN if ( sWoundAmt > 1 ) { - pSoldier->inv[ bPosOfMask ].bStatus[0] -= (INT8) Random( 4 ); - sWoundAmt = ( sWoundAmt * ( 100 - pSoldier->inv[ bPosOfMask ].bStatus[0] ) ) / 100; + pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] -= (INT8) Random( 4 ); + sWoundAmt = ( sWoundAmt * ( 100 - pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] ) ) / 100; } else if ( sWoundAmt == 1 ) { - pSoldier->inv[ bPosOfMask ].bStatus[0] -= (INT8) Random( 2 ); + pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] -= (INT8) Random( 2 ); } } } @@ -1532,12 +1532,12 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN { if ( sWoundAmt == 1 ) { - pSoldier->inv[ bPosOfMask ].bStatus[0] -= (INT8) Random( 2 ); + pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] -= (INT8) Random( 2 ); } else { // use up gas mask - pSoldier->inv[ bPosOfMask ].bStatus[0] -= (INT8) Random( 4 ); + pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] -= (INT8) Random( 4 ); } } sWoundAmt = 0; @@ -2468,10 +2468,10 @@ void ToggleActionItemsByFrequency( INT8 bFrequency ) if (gWorldBombs[uiWorldBombIndex].fExists) { pObj = &( gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].o ); - if ( pObj->bDetonatorType == BOMB_REMOTE ) + if ( pObj->ItemData.Trigger.bDetonatorType == BOMB_REMOTE ) { // Found a remote bomb, so check to see if it has the same frequency - if (pObj->bFrequency == bFrequency) + if (pObj->ItemData.Trigger.BombTrigger.bFrequency == bFrequency) { // toggle its active flag if (pObj->fFlags & OBJECT_DISABLED_BOMB) @@ -2499,7 +2499,7 @@ void TogglePressureActionItemsInGridNo( INT16 sGridNo ) if ( gWorldBombs[uiWorldBombIndex].fExists && gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].sGridNo == sGridNo ) { pObj = &( gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].o ); - if ( pObj->bDetonatorType == BOMB_PRESSURE ) + if ( pObj->ItemData.Trigger.bDetonatorType == BOMB_PRESSURE ) { // Found a pressure item // toggle its active flag @@ -2560,7 +2560,7 @@ void PerformItemAction( INT16 sGridNo, OBJECTTYPE * pObj ) { STRUCTURE * pStructure; - switch( pObj->bActionValue ) + switch( pObj->ItemData.Trigger.bActionValue ) { case ACTION_ITEM_OPEN_DOOR: pStructure = FindStructure( sGridNo, STRUCTURE_ANYDOOR ); @@ -2890,7 +2890,7 @@ void PerformItemAction( INT16 sGridNo, OBJECTTYPE * pObj ) if ( sDoorSpot != NOWHERE && sTeleportSpot != NOWHERE ) { // close the door... - DoorCloser.bActionValue = ACTION_ITEM_CLOSE_DOOR; + DoorCloser.ItemData.Trigger.bActionValue = ACTION_ITEM_CLOSE_DOOR; PerformItemAction( sDoorSpot, &DoorCloser ); // have sex @@ -2999,17 +2999,17 @@ void HandleExplosionQueue( void ) sGridNo = gWorldItems[ gWorldBombs[ uiWorldBombIndex ].iItemIndex ].sGridNo; ubLevel = gWorldItems[ gWorldBombs[ uiWorldBombIndex ].iItemIndex ].ubLevel; - if (pObj->usItem == ACTION_ITEM && pObj->bActionValue != ACTION_ITEM_BLOW_UP) + if (pObj->usItem == ACTION_ITEM && pObj->ItemData.Trigger.bActionValue != ACTION_ITEM_BLOW_UP) { PerformItemAction( sGridNo, pObj ); } - else if ( pObj->usBombItem == TRIP_KLAXON ) + else if ( pObj->ItemData.Trigger.usBombItem == TRIP_KLAXON ) { PlayJA2Sample( KLAXON_ALARM, RATE_11025, SoundVolume( MIDVOLUME, sGridNo ), 5, SoundDir( sGridNo ) ); CallAvailableEnemiesTo( sGridNo ); //RemoveItemFromPool( sGridNo, gWorldBombs[ uiWorldBombIndex ].iItemIndex, 0 ); } - else if ( pObj->usBombItem == TRIP_FLARE ) + else if ( pObj->ItemData.Trigger.usBombItem == TRIP_FLARE ) { NewLightEffect( sGridNo, (UINT8)Explosive[pObj->usItem].ubDuration, (UINT8)Explosive[pObj->usItem].ubStartRadius ); RemoveItemFromPool( sGridNo, gWorldBombs[ uiWorldBombIndex ].iItemIndex, ubLevel ); @@ -3032,14 +3032,14 @@ void HandleExplosionQueue( void ) // BOOM! // bomb objects only store the SIDE who placed the bomb! :-( - if ( pObj->ubBombOwner > 1 ) + if ( pObj->ItemData.Trigger.ubBombOwner > 1 ) { - IgniteExplosion( (UINT8) (pObj->ubBombOwner - 2), CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, pObj->usBombItem, ubLevel ); + IgniteExplosion( (UINT8) (pObj->ItemData.Trigger.ubBombOwner - 2), CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, pObj->ItemData.Trigger.usBombItem, ubLevel ); } else { // pre-placed - IgniteExplosion( NOBODY, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, pObj->usBombItem, ubLevel ); + IgniteExplosion( NOBODY, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, pObj->ItemData.Trigger.usBombItem, ubLevel ); } } @@ -3117,25 +3117,25 @@ void DecayBombTimers( void ) if (gWorldBombs[uiWorldBombIndex].fExists) { pObj = &( gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].o ); - if ( pObj->bDetonatorType == BOMB_TIMED && !(pObj->fFlags & OBJECT_DISABLED_BOMB) ) + if ( pObj->ItemData.Trigger.bDetonatorType == BOMB_TIMED && !(pObj->fFlags & OBJECT_DISABLED_BOMB) ) { // Found a timed bomb, so decay its delay value and see if it goes off - pObj->bDelay--; - if (pObj->bDelay == 0) + pObj->ItemData.Trigger.BombTrigger.bDelay--; + if (pObj->ItemData.Trigger.BombTrigger.bDelay == 0) { // put this bomb on the queue AddBombToQueue( uiWorldBombIndex, uiTimeStamp ); // ATE: CC black magic.... - if ( pObj->ubBombOwner > 1 ) + if ( pObj->ItemData.Trigger.ubBombOwner > 1 ) { - gubPersonToSetOffExplosions = (UINT8) (pObj->ubBombOwner - 2); + gubPersonToSetOffExplosions = (UINT8) (pObj->ItemData.Trigger.ubBombOwner - 2); } else { gubPersonToSetOffExplosions = NOBODY; } - if (pObj->usItem != ACTION_ITEM || pObj->bActionValue == ACTION_ITEM_BLOW_UP) + if (pObj->usItem != ACTION_ITEM || pObj->ItemData.Trigger.bActionValue == ACTION_ITEM_BLOW_UP) { uiTimeStamp += BOMB_QUEUE_DELAY; } @@ -3159,17 +3159,17 @@ void SetOffBombsByFrequency( UINT8 ubID, INT8 bFrequency ) if (gWorldBombs[uiWorldBombIndex].fExists) { pObj = &( gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].o ); - if ( pObj->bDetonatorType == BOMB_REMOTE && !(pObj->fFlags & OBJECT_DISABLED_BOMB) ) + if ( pObj->ItemData.Trigger.bDetonatorType == BOMB_REMOTE && !(pObj->fFlags & OBJECT_DISABLED_BOMB) ) { // Found a remote bomb, so check to see if it has the same frequency - if (pObj->bFrequency == bFrequency) + if (pObj->ItemData.Trigger.BombTrigger.bFrequency == bFrequency) { gubPersonToSetOffExplosions = ubID; // put this bomb on the queue AddBombToQueue( uiWorldBombIndex, uiTimeStamp ); - if (pObj->usItem != ACTION_ITEM || pObj->bActionValue == ACTION_ITEM_BLOW_UP) + if (pObj->usItem != ACTION_ITEM || pObj->ItemData.Trigger.bActionValue == ACTION_ITEM_BLOW_UP) { uiTimeStamp += BOMB_QUEUE_DELAY; } @@ -3234,7 +3234,7 @@ BOOLEAN SetOffBombsInGridNo( UINT8 ubID, INT16 sGridNo, BOOLEAN fAllBombs, INT8 pObj = &( gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].o ); if (!(pObj->fFlags & OBJECT_DISABLED_BOMB)) { - if (fAllBombs || pObj->bDetonatorType == BOMB_PRESSURE) + if (fAllBombs || pObj->ItemData.Trigger.bDetonatorType == BOMB_PRESSURE) { // Snap: if we do set off our own trap (e.g. by trying to disarm it), we pay! /*if (!fAllBombs && MercPtrs[ ubID ]->bTeam != gbPlayerNum ) @@ -3258,7 +3258,7 @@ BOOLEAN SetOffBombsInGridNo( UINT8 ubID, INT16 sGridNo, BOOLEAN fAllBombs, INT8 { // send out a signal to detonate other bombs, rather than this which // isn't a bomb but a trigger - SetOffBombsByFrequency( ubID, pObj->bFrequency ); + SetOffBombsByFrequency( ubID, pObj->ItemData.Trigger.BombTrigger.bFrequency ); } else { @@ -3266,12 +3266,12 @@ BOOLEAN SetOffBombsInGridNo( UINT8 ubID, INT16 sGridNo, BOOLEAN fAllBombs, INT8 // put this bomb on the queue AddBombToQueue( uiWorldBombIndex, uiTimeStamp ); - if (pObj->usItem != ACTION_ITEM || pObj->bActionValue == ACTION_ITEM_BLOW_UP) + if (pObj->usItem != ACTION_ITEM || pObj->ItemData.Trigger.bActionValue == ACTION_ITEM_BLOW_UP) { uiTimeStamp += BOMB_QUEUE_DELAY; } - if ( pObj->usBombItem != NOTHING && Item[ pObj->usBombItem ].usItemClass & IC_EXPLOSV ) + if ( pObj->ItemData.Trigger.usBombItem != NOTHING && Item[ pObj->ItemData.Trigger.usBombItem ].usItemClass & IC_EXPLOSV ) { fFoundMine = TRUE; } @@ -3296,7 +3296,7 @@ void ActivateSwitchInGridNo( UINT8 ubID, INT16 sGridNo ) { pObj = &( gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].o ); - if ( pObj->usItem == SWITCH && ( !(pObj->fFlags & OBJECT_DISABLED_BOMB) ) && pObj->bDetonatorType == BOMB_SWITCH) + if ( pObj->usItem == SWITCH && ( !(pObj->fFlags & OBJECT_DISABLED_BOMB) ) && pObj->ItemData.Trigger.bDetonatorType == BOMB_SWITCH) { // send out a signal to detonate other bombs, rather than this which // isn't a bomb but a trigger @@ -3305,7 +3305,7 @@ void ActivateSwitchInGridNo( UINT8 ubID, INT16 sGridNo ) // No, not a good idea. // gTacticalStatus.ubAttackBusyCount = 0; - SetOffBombsByFrequency( ubID, pObj->bFrequency ); + SetOffBombsByFrequency( ubID, pObj->ItemData.Trigger.BombTrigger.bFrequency ); } } } @@ -3631,7 +3631,7 @@ INT32 FindActiveTimedBomb( void ) if (gWorldBombs[uiWorldBombIndex].fExists) { pObj = &( gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].o ); - if ( pObj->bDetonatorType == BOMB_TIMED && !(pObj->fFlags & OBJECT_DISABLED_BOMB) ) + if ( pObj->ItemData.Trigger.bDetonatorType == BOMB_TIMED && !(pObj->fFlags & OBJECT_DISABLED_BOMB) ) { return( gWorldBombs[uiWorldBombIndex].iItemIndex ); } diff --git a/TileEngine/physics.cpp b/TileEngine/physics.cpp index 283b5547..23802699 100644 --- a/TileEngine/physics.cpp +++ b/TileEngine/physics.cpp @@ -2478,7 +2478,7 @@ void HandleArmedObjectImpact( REAL_OBJECT *pObject ) #ifdef TESTDUDEXPLOSIVES if ( sZ != 0 || pObject->fInWater ) #else - if ( sZ != 0 || pObject->fInWater || ( pObj->bStatus[0] >= USABLE && ( PreRandom( 100 ) < (UINT32) pObj->bStatus[0] + PreRandom( 50 ) ) ) ) + if ( sZ != 0 || pObject->fInWater || ( pObj->ItemData.Generic.bStatus[0] >= USABLE && ( PreRandom( 100 ) < (UINT32) pObj->ItemData.Generic.bStatus[0] + PreRandom( 50 ) ) ) ) #endif { fDoImpact = TRUE; @@ -2488,7 +2488,7 @@ void HandleArmedObjectImpact( REAL_OBJECT *pObject ) #ifdef TESTDUDEXPLOSIVES if ( 1 ) #else - if ( pObj->bStatus[0] >= USABLE && PreRandom(100) < (UINT32) pObj->bStatus[0] + PreRandom( 50 ) ) + if ( pObj->ItemData.Generic.bStatus[0] >= USABLE && PreRandom(100) < (UINT32) pObj->ItemData.Generic.bStatus[0] + PreRandom( 50 ) ) #endif { iTrapped = PreRandom( 4 ) + 2; @@ -2499,8 +2499,8 @@ void HandleArmedObjectImpact( REAL_OBJECT *pObject ) // Start timed bomb... usFlags |= WORLD_ITEM_ARMED_BOMB; - pObj->bDetonatorType = BOMB_TIMED; - pObj->bDelay = (INT8)( 1 + PreRandom( 2 ) ); + pObj->ItemData.Trigger.bDetonatorType = BOMB_TIMED; + pObj->ItemData.Trigger.BombTrigger.bDelay = (INT8)( 1 + PreRandom( 2 ) ); } // ATE: If we have collided with roof last... diff --git a/TileEngine/pits.cpp b/TileEngine/pits.cpp index 5264c8e7..0575fcd5 100644 --- a/TileEngine/pits.cpp +++ b/TileEngine/pits.cpp @@ -180,9 +180,9 @@ void AddAllPits() { if( gWorldItems[ i ].o.usItem == ACTION_ITEM ) { - if( gWorldItems[ i ].o.bActionValue == ACTION_ITEM_SMALL_PIT ) + if( gWorldItems[ i ].o.ItemData.Trigger.bActionValue == ACTION_ITEM_SMALL_PIT ) Add3X3Pit( gWorldItems[ i ].sGridNo ); - else if( gWorldItems[ i ].o.bActionValue == ACTION_ITEM_LARGE_PIT ) + else if( gWorldItems[ i ].o.ItemData.Trigger.bActionValue == ACTION_ITEM_LARGE_PIT ) Add5X5Pit( gWorldItems[ i ].sGridNo ); } } @@ -195,9 +195,9 @@ void RemoveAllPits() { if( gWorldItems[ i ].o.usItem == ACTION_ITEM ) { - if( gWorldItems[ i ].o.bActionValue == ACTION_ITEM_SMALL_PIT ) + if( gWorldItems[ i ].o.ItemData.Trigger.bActionValue == ACTION_ITEM_SMALL_PIT ) Remove3X3Pit( gWorldItems[ i ].sGridNo ); - else if( gWorldItems[ i ].o.bActionValue == ACTION_ITEM_LARGE_PIT ) + else if( gWorldItems[ i ].o.ItemData.Trigger.bActionValue == ACTION_ITEM_LARGE_PIT ) Remove5X5Pit( gWorldItems[ i ].sGridNo ); } } diff --git a/ja2_2005Express.vcproj b/ja2_2005Express.vcproj index e752962a..5dd7fe3b 100644 --- a/ja2_2005Express.vcproj +++ b/ja2_2005Express.vcproj @@ -1,7 +1,7 @@