Merged revision(s) 6894 from branches/ja2_source_official_2014:

Fixes (by Buggler)
- IMPPrejudice page not showing when reviewing in finish mode
- Added message when minor traits are unselectable due to all IMP available slots taken up by major traits
- Display message when pressing hotkey 'G' to toggle artificial merc light
- refactor hotkey weapon switching and make function available in OIV too
- hold ALT key to swap item instead of opening description box for valid attachment on cursor

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6895 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2014-02-10 00:28:04 +00:00
parent 8d07ebccc0
commit cb3304e93f
17 changed files with 151 additions and 139 deletions
+14 -9
View File
@@ -3574,7 +3574,7 @@ BOOLEAN UIHandleItemPlacement( UINT8 ubHandPos, UINT16 usOldItemIndex, UINT16 us
}
//Jenilee
INT32 uiLastHandPos = -1;
INT32 iLastHandPos = -1;
#define SLOT_NONE 0
#define SLOT_HANDS 1
@@ -3636,7 +3636,7 @@ UINT16 uiOIVSlotType[NUM_INV_SLOTS] = {
0, 0, 0, 0, 0, 0 //49-54
};
UINT32 GetInvMovementCost(OBJECTTYPE* pObj, UINT32 old_pos, UINT32 new_pos)
UINT16 GetInvMovementCost(OBJECTTYPE* pObj, INT16 old_pos, INT16 new_pos)
{
if (!(gTacticalStatus.uiFlags & INCOMBAT) || //Not in combat
(old_pos == -1 || new_pos == -1)|| //Either position is invalid
@@ -3724,7 +3724,7 @@ UINT32 GetInvMovementCost(OBJECTTYPE* pObj, UINT32 old_pos, UINT32 new_pos)
void SMInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason )
{
UINT32 uiHandPos;
// Copyies of values
// Copies of values
UINT16 usOldItemIndex, usNewItemIndex;
UINT16 usItemPrevInItemPointer;
UINT16 usCostToMoveItem = 0; //Jenilee
@@ -3826,7 +3826,7 @@ void SMInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason )
usOldItemIndex = gpSMCurrentMerc->inv[ uiHandPos ].usItem;
//Jenilee: remember our last selected slot
uiLastHandPos = uiHandPos;
iLastHandPos = uiHandPos;
// move item into the mouse cursor
@@ -3859,7 +3859,7 @@ void SMInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason )
return;
if (INV_AP_COST)
//Jenilee: determine the cost of moving this item around in our inventory
usCostToMoveItem = GetInvMovementCost(gpItemPointer, uiLastHandPos, uiHandPos);
usCostToMoveItem = GetInvMovementCost(gpItemPointer, iLastHandPos, uiHandPos);
// Flugente: backgrounds
usCostToMoveItem = (usCostToMoveItem * (100 + gpSMCurrentMerc->GetBackgroundValue(BG_INVENTORY))) / 100;
@@ -3867,14 +3867,14 @@ void SMInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason )
if ( ( usCostToMoveItem == 0 ) || ( gpSMCurrentMerc->bActionPoints >= usCostToMoveItem ) )
{
fOKToGo = TRUE;
//uiLastHandPos = uiHandPos;//dnl ch66 070913 this should be set after we move item
//iLastHandPos = uiHandPos;//dnl ch66 070913 this should be set after we move item
}
else //we dont have enough APs to move it to this slot, show a warning message
{
// silversurfer: What if our old slot is occupied now (could happen when we swap items)?
// We will be stuck with an item at the hand cursor and nowhere to put it -> bad. :-(
// So let's check if our old slot is empty and if it is not allow item placement anyway.
if ( gpSMCurrentMerc->inv[ uiLastHandPos ].usItem == NULL )
if ( gpSMCurrentMerc->inv[ iLastHandPos ].usItem == NULL )
{
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[NOT_ENOUGH_APS_STR]);
fOKToGo = FALSE;
@@ -3958,8 +3958,13 @@ void SMInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason )
return;
}
// hold ALT key to swap valid attachment item instead
if ( _KeyDown(ALT) )
{
// do nothing
}
// we allow attaching on items in any slot
if ( ValidAttachment( usNewItemIndex, &(gpSMCurrentMerc->inv[uiHandPos]) ) )
else if ( ValidAttachment( usNewItemIndex, &(gpSMCurrentMerc->inv[uiHandPos]) ) )
{
// it's an attempt to attach; bring up the inventory panel
if ( !InItemDescriptionBox( ) )
@@ -4029,7 +4034,7 @@ void SMInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason )
// try to place the item in the cursor into this inventory slot
if ( UIHandleItemPlacement( (UINT8) uiHandPos, usOldItemIndex, usNewItemIndex, fDeductPoints ) )
{
uiLastHandPos = uiHandPos;//dnl ch66 070913
iLastHandPos = uiHandPos;//dnl ch66 070913
//Jenilee: pay the price
//just make sure to handle that if we are putting it back in the SAME slot, the cost should be 0!!!
gpSMCurrentMerc->bActionPoints -= usCostToMoveItem;
+3
View File
@@ -168,4 +168,7 @@ extern UINT8 gubDescBoxLine;
// Record how many lines there are for the current item in the Advanced tab.
extern UINT8 gubDescBoxTotalAdvLines;
// Jenilee: determine the cost of moving this item around in our inventory
UINT16 GetInvMovementCost(OBJECTTYPE* pObj, INT16 old_pos, INT16 new_pos);
#endif
+61 -77
View File
@@ -92,6 +92,7 @@
#include "Debug Control.h"
#include "LOS.h" // added by SANDRO
#include "CampaignStats.h" // added by Flugente
#include "Interface Panels.h"
#endif
#include "ub_config.h"
@@ -16291,16 +16292,35 @@ void SOLDIERTYPE::TakeNewBombFromIventory(UINT16 item)
// Flugente: switch hand item for gunsling weapon, or pistol, or knife
void SOLDIERTYPE::SwitchWeapons( BOOLEAN fKnife, BOOLEAN fSideArm )
{
// NIV-only
if ( !UsingNewInventorySystem() )
return;
UINT8 pocketsearch, retrieveslot, handobjstorageslot;
BOOLEAN handCanMove, searchitemCanMove;
// The slot we move our hand object from and the new object to is obviously always HANDPOS
// first pocket to search in OIV & NIV
if ( UsingNewInventorySystem() )
pocketsearch = GUNSLINGPOCKPOS;
else
pocketsearch = BIGPOCK1POS;
// The second slot is the one from where we retrieve the object we search
UINT8 retrieveslot = GUNSLINGPOCKPOS;
if ( UsingNewInventorySystem() )
retrieveslot = GUNSLINGPOCKPOS;
else // search for gun in OIV
{
for(UINT8 i = pocketsearch; i < NUM_INV_SLOTS; ++i)
{
// we use the first gun we can find
if ( this->inv[i].exists() && Item[this->inv[i].usItem].usItemClass & IC_GUN && this->inv[i].ubNumberOfObjects == 1 )
{
retrieveslot = i;
break;
}
}
}
// The third slot is where we put our hand item into
UINT8 handobjstorageslot = HANDPOS;
handobjstorageslot = HANDPOS;
// if we swap knifes or sidearms, we search for any such item if we do not already have it in our hands. If we do, we instead search for a gun to switch
if ( fKnife )
@@ -16308,7 +16328,7 @@ void SOLDIERTYPE::SwitchWeapons( BOOLEAN fKnife, BOOLEAN fSideArm )
// if we already have a knife in hand, search for a gun instead
if ( this->inv[HANDPOS].exists() && Item[this->inv[HANDPOS].usItem].usItemClass & IC_BLADE )
{
for(UINT8 i = GUNSLINGPOCKPOS; i < NUM_INV_SLOTS; ++i)
for(UINT8 i = pocketsearch; i < NUM_INV_SLOTS; ++i)
{
// we use the first gun we can find
if ( this->inv[i].exists() && Item[this->inv[i].usItem].usItemClass & IC_GUN && this->inv[i].ubNumberOfObjects == 1 )
@@ -16321,7 +16341,7 @@ void SOLDIERTYPE::SwitchWeapons( BOOLEAN fKnife, BOOLEAN fSideArm )
// search for a knife
else
{
for(UINT8 i = GUNSLINGPOCKPOS; i < NUM_INV_SLOTS; ++i)
for(UINT8 i = pocketsearch; i < NUM_INV_SLOTS; ++i)
{
// take first blade
if ( this->inv[i].exists() && Item[this->inv[i].usItem].usItemClass & IC_BLADE && this->inv[i].ubNumberOfObjects == 1 )
@@ -16334,10 +16354,11 @@ void SOLDIERTYPE::SwitchWeapons( BOOLEAN fKnife, BOOLEAN fSideArm )
}
else if ( fSideArm )
{
// if we already have a sidearm in hand, search for a gun tat isn't a sidearm instead
if ( this->inv[HANDPOS].exists() && Item[this->inv[HANDPOS].usItem].usItemClass & IC_GUN && Weapon[ Item[ this->inv[HANDPOS].usItem ].ubClassIndex ].ubWeaponClass == HANDGUNCLASS )
// if we already have a sidearm in hand, search for a gun that isn't a sidearm instead
if ( this->inv[HANDPOS].exists() && Item[this->inv[HANDPOS].usItem].usItemClass & IC_GUN
&& Weapon[ Item[ this->inv[HANDPOS].usItem ].ubClassIndex ].ubWeaponClass == HANDGUNCLASS )
{
for(UINT8 i = GUNSLINGPOCKPOS; i < NUM_INV_SLOTS; ++i)
for(UINT8 i = pocketsearch; i < NUM_INV_SLOTS; ++i)
{
// we use the first gun we can find
if ( this->inv[i].exists() && Item[this->inv[i].usItem].usItemClass & IC_GUN && Weapon[ Item[ this->inv[i].usItem ].ubClassIndex ].ubWeaponClass != HANDGUNCLASS && this->inv[i].ubNumberOfObjects == 1 )
@@ -16350,9 +16371,9 @@ void SOLDIERTYPE::SwitchWeapons( BOOLEAN fKnife, BOOLEAN fSideArm )
// search for a sidearm
else
{
for(UINT8 i = GUNSLINGPOCKPOS; i < NUM_INV_SLOTS; ++i)
for(UINT8 i = pocketsearch; i < NUM_INV_SLOTS; ++i)
{
// take first blade
// take first handgun
if ( this->inv[i].exists() && Item[this->inv[i].usItem].usItemClass & IC_GUN && Weapon[ Item[ this->inv[i].usItem ].ubClassIndex ].ubWeaponClass == HANDGUNCLASS && this->inv[i].ubNumberOfObjects == 1 )
{
retrieveslot = i;
@@ -16363,9 +16384,9 @@ void SOLDIERTYPE::SwitchWeapons( BOOLEAN fKnife, BOOLEAN fSideArm )
}
// search a slot to put our hand object into
for(UINT8 i = GUNSLINGPOCKPOS; i < NUM_INV_SLOTS; ++i)
for(UINT8 i = pocketsearch; i < NUM_INV_SLOTS; ++i)
{
// take first slot that hadn item would fit
// take first slot that hand item would fit
if ( CanItemFitInPosition(this, &this->inv[HANDPOS], i, FALSE) )
{
if ( i == retrieveslot || !this->inv[i].exists() )
@@ -16376,77 +16397,34 @@ void SOLDIERTYPE::SwitchWeapons( BOOLEAN fKnife, BOOLEAN fSideArm )
}
}
BOOLEAN handcanMove = (CanItemFitInPosition(this, &this->inv[HANDPOS], handobjstorageslot, FALSE) || (this->inv[HANDPOS].exists() == false && this->inv[SECONDHANDPOS].exists() == false));
BOOLEAN searchitemCanMove = (CanItemFitInPosition(this, &this->inv[retrieveslot], HANDPOS, FALSE) || this->inv[retrieveslot].exists() == false);
if(Item[this->inv[retrieveslot].usItem].twohanded && this->inv[SECONDHANDPOS].exists() == true)
handcanMove = FALSE;
// check both items can be moved
// check HANDPOS item that cannot be moved to inventory
if( handobjstorageslot == HANDPOS && this->inv[HANDPOS].exists() == true )
handCanMove = FALSE;
else
handCanMove = (CanItemFitInPosition(this, &this->inv[HANDPOS], handobjstorageslot, FALSE) || (this->inv[HANDPOS].exists() == false && this->inv[SECONDHANDPOS].exists() == false));
if( handcanMove == TRUE && searchitemCanMove == TRUE)
if( Item[this->inv[retrieveslot].usItem].twohanded && this->inv[SECONDHANDPOS].exists() == true )
searchitemCanMove = FALSE;
else
searchitemCanMove = (CanItemFitInPosition(this, &this->inv[retrieveslot], HANDPOS, FALSE) || this->inv[retrieveslot].exists() == false);
// execute swap
if( handCanMove == TRUE && searchitemCanMove == TRUE)
{
if (gGameOptions.fInventoryCostsAP)
{
UINT8 APCost = 0;
UINT8 APTotalCost = 0;
if (gGameExternalOptions.uWeightDivisor != 0)
{
// we need to determine moving costs according to slots
INT16 fromretrieve = uiNIVSlotType[retrieveslot];
INT16 tohand = uiNIVSlotType[HANDPOS];
INT16 fromhand = uiNIVSlotType[HANDPOS];
INT16 tostorage = uiNIVSlotType[handobjstorageslot];
UINT16 APTotalCost = 0;
if (this->inv[retrieveslot].exists())
APTotalCost += GetInvMovementCost(&this->inv[retrieveslot], retrieveslot, HANDPOS);
//If these 2 arrays are initiated outside the function, APBPConstants will not have been initialized, and all values will be 0
INT16 uiAPCostFromSlot[12] =
{
APBPConstants[AP_INV_FROM_NONE],
APBPConstants[AP_INV_FROM_HANDS],
APBPConstants[AP_INV_FROM_EQUIPMENT],
APBPConstants[AP_INV_FROM_VEST],
APBPConstants[AP_INV_FROM_RIG],
APBPConstants[AP_INV_FROM_CPACK],
APBPConstants[AP_INV_FROM_BPACK],
APBPConstants[AP_INV_FROM_SLING],
APBPConstants[AP_INV_FROM_KNIFE],
APBPConstants[AP_INV_FROM_FACE],
APBPConstants[AP_INV_FROM_BIG_POCKET],
APBPConstants[AP_INV_FROM_SMALL_POCKET]
};
INT16 uiAPCostToSlot[12] =
{
APBPConstants[AP_INV_TO_NONE],
APBPConstants[AP_INV_TO_HANDS],
APBPConstants[AP_INV_TO_EQUIPMENT],
APBPConstants[AP_INV_TO_VEST],
APBPConstants[AP_INV_TO_RIG],
APBPConstants[AP_INV_TO_CPACK],
APBPConstants[AP_INV_TO_BPACK],
APBPConstants[AP_INV_TO_SLING],
APBPConstants[AP_INV_TO_KNIFE],
APBPConstants[AP_INV_TO_FACE],
APBPConstants[AP_INV_TO_BIG_POCKET],
APBPConstants[AP_INV_TO_SMALL_POCKET]
};
if (this->inv[retrieveslot].exists())
{
APCost = ( uiAPCostFromSlot[ fromretrieve ] + uiAPCostToSlot [ tohand ] );
INT16 weight = (int)((Item[this->inv[retrieveslot].usItem].ubWeight) / gGameExternalOptions.uWeightDivisor);
APCost += DynamicAdjustAPConstants(weight, weight);
APTotalCost += __min(APCost, APBPConstants[AP_INV_MAX_COST]);
}
if (this->inv[HANDPOS].exists())
{
APCost = ( uiAPCostFromSlot [ fromhand ] + uiAPCostToSlot [ tostorage ] );
INT16 weight = (int)((Item[this->inv[HANDPOS].usItem].ubWeight) / gGameExternalOptions.uWeightDivisor);
APCost += DynamicAdjustAPConstants(weight, weight);
APTotalCost += __min(APCost, APBPConstants[AP_INV_MAX_COST]);
}
}
if (this->inv[HANDPOS].exists())
APTotalCost += GetInvMovementCost(&this->inv[HANDPOS], HANDPOS, handobjstorageslot);
if (this->bActionPoints >= APTotalCost)
{
// SANDRO - I dared to change this to use the apropriate function, as that function is actually important for IIS
// SANDRO - I dared to change this to use the appropriate function, as that function is actually important for IIS
//pSoldier->bActionPoints -= APTotalCost;
DeductPoints( this, APTotalCost, 0 );
@@ -20353,9 +20331,15 @@ void HandlePlayerTogglingLightEffects( BOOLEAN fToggleValue )
{
//Toggle light status
if ( gGameSettings.fOptions[ TOPTION_MERC_CASTS_LIGHT ] )
{
gGameSettings.fOptions[ TOPTION_MERC_CASTS_LIGHT ] = FALSE;
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_MERC_CASTS_LIGHT_OFF ] );
}
else
{
gGameSettings.fOptions[ TOPTION_MERC_CASTS_LIGHT ] = TRUE;
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_MERC_CASTS_LIGHT_ON ] );
}
}
//Update all the mercs in the sector
+3 -3
View File
@@ -3245,13 +3245,13 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
{
gGameSettings.fOptions[ TOPTION_TRACKING_MODE ] = FALSE;
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_TACKING_MODE_OFF ] );
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_TRACKING_MODE_OFF ] );
}
else
{
gGameSettings.fOptions[ TOPTION_TRACKING_MODE ] = TRUE;
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_TACKING_MODE_ON ] );
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_TRACKING_MODE_ON ] );
}
}
else
@@ -3521,7 +3521,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
case 'K':
// Flugente: reworked this
//CHRISL: Swap gunsling
if ( gusSelectedSoldier != NOBODY && UsingNewInventorySystem() == true)
if ( gusSelectedSoldier != NOBODY )
{
SOLDIERTYPE *pSoldier = MercPtrs[ gusSelectedSoldier ];