Allow different rules for climbing (and jumping) with backpacks (by JMich)

- ja2_options.ini: MAX_BACKPACK_WEIGHT_TO_CLIMB, USE_GLOBAL_BACKPACK_SETTINGS
- First setting is sBackpackWeightToClimb which is the maximum weight a backpack can weigh and still allow you to climb with. The sBackpackWeightModifier in items.xml can modify that number by either making it harder (positive number modifier) or easier (negative number modifier). If the sBackpackWeightToClimb is -1 (default) then the option is unused.
Second setting is fUseGlobalBackpackSettings which if true (default) uses the same rules for all backpacks, while if false it checks for the fAllowClimbing tag in items.xml, and if that is true you can climb with said backpack.
Both options can be used at the same time, so you may climb with (for example) a malice backpack that weighs less than 5kg (or 50 hg) but not climb with a radio set.



git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7146 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2014-04-11 07:16:46 +00:00
parent d4620ffebc
commit ec481e8209
10 changed files with 105 additions and 18 deletions
+4
View File
@@ -1343,6 +1343,10 @@ void LoadGameExternalOptions()
gGameExternalOptions.fCanJumpThroughWindows = iniReader.ReadBoolean("Tactical Gameplay Settings","CAN_JUMP_THROUGH_WINDOWS", FALSE);
gGameExternalOptions.fCanJumpThroughClosedWindows = iniReader.ReadBoolean("Tactical Gameplay Settings","CAN_JUMP_THROUGH_CLOSED_WINDOWS", TRUE);
gGameExternalOptions.fCanClimbOnWalls = iniReader.ReadBoolean("Tactical Gameplay Settings","CAN_CLIMB_ON_WALLS", FALSE);
//JMich.BackpackClimb
gGameExternalOptions.sBackpackWeightToClimb = iniReader.ReadInteger("Tactical Gameplay Settings", "MAX_BACKPACK_WEIGHT_TO_CLIMB", -1);
gGameExternalOptions.fUseGlobalBackpackSettings = iniReader.ReadBoolean("Tactical Gameplay Settings", "USE_GLOBAL_BACKPACK_SETTINGS", TRUE);
// sevenfm
gGameExternalOptions.fShowEnemyWeapon = iniReader.ReadBoolean("Tactical Gameplay Settings","SHOW_ENEMY_WEAPON", FALSE);
+4
View File
@@ -1199,6 +1199,10 @@ typedef struct
BOOLEAN fCanJumpThroughClosedWindows;
BOOLEAN fCanClimbOnWalls;
//JMich.BackpackClimb
INT16 sBackpackWeightToClimb;
BOOLEAN fUseGlobalBackpackSettings;
// sevenfm: show enemy weapon above soldier in tactical
BOOLEAN fShowEnemyWeapon;
BOOLEAN fShowEnemyExtendedInfo;
+4
View File
@@ -1168,6 +1168,10 @@ typedef struct
// Flugente: spoting effectiveness
INT16 usSpotting;
//JMich.BackpackClimb
INT16 sBackpackWeightModifier; //modifier to weight calculation to climb.
BOOLEAN fAllowClimbing; //does item allow climbing while wearing it
} INVTYPE;
+5 -1
View File
@@ -2021,7 +2021,11 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE
// CHRISL: Added penalty for jumping a fence while wearing a backpack
// Do we have APs?
// SANDRO - changed the static values to precise calculation here
if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true)
if ((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
{
sAPCost = GetAPsToJumpFence( pSoldier, TRUE );
sBPCost = GetBPsToJumpFence( pSoldier, TRUE );
+10 -2
View File
@@ -2104,7 +2104,11 @@ void HandleMouseRTX1Button( UINT32 *puiNewEvent )
BOOLEAN fNearLowerLevel;
INT8 bDirection;
// CHRISL: Turn off manual jumping while wearing a backpack
if(UsingNewInventorySystem() == true && pjSoldier->inv[BPACKPOCKPOS].exists() == true)
if (UsingNewInventorySystem() == true && pjSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
return;
// Make sure the merc is not collapsed!
@@ -2197,7 +2201,11 @@ void HandleRTJump( void )
BOOLEAN fNearLowerLevel;
INT8 bDirection;
// CHRISL: Turn off manual jumping while wearing a backpack
if(UsingNewInventorySystem() == true && pjSoldier->inv[BPACKPOCKPOS].exists() == true)
if (UsingNewInventorySystem() == true && pjSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
return;
// Make sure the merc is not collapsed!
+5 -1
View File
@@ -9125,7 +9125,11 @@ void SOLDIERTYPE::BeginSoldierClimbUpRoof( void )
{
//CHRISL: Disable climbing up to a roof while wearing a backpack
if((UsingNewInventorySystem() == true) && this->inv[BPACKPOCKPOS].exists() == true) {
if ((UsingNewInventorySystem() == true) && this->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)this->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[this->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[this->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
{
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, NewInvMessage[NIV_NO_CLIMB] );
return;
}
+50 -10
View File
@@ -2846,7 +2846,11 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
if ( FindWindowJumpDirection( lSoldier, lSoldier->sGridNo, lSoldier->ubDirection, &bDirection ) )
{
if((UsingNewInventorySystem() == true) && lSoldier->inv[BPACKPOCKPOS].exists() == true)
if ((UsingNewInventorySystem() == true) && lSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)lSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[lSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[lSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
{
//Moa: no jumping with backpack
//sAPCost = GetAPsToJumpThroughWindows( lSoldier, TRUE );
@@ -2916,7 +2920,11 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
if ( fNearLowerLevel )
{
// No climbing when wearing a backpack!
if((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true)
if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
return;
if ( EnoughPoints( pjSoldier, GetAPsToClimbRoof( pjSoldier, TRUE ), GetBPsToClimbRoof( pjSoldier, TRUE ), FALSE ) )
@@ -2927,7 +2935,11 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
if ( fNearHeigherLevel )
{
// No climbing when wearing a backpack!
if((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true)
if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
return;
if ( EnoughPoints( pjSoldier, GetAPsToClimbRoof( pjSoldier, FALSE ), GetBPsToClimbRoof( pjSoldier, FALSE ), FALSE ) )
@@ -2939,7 +2951,11 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
// Jump over fence
if ( FindFenceJumpDirection( pjSoldier, pjSoldier->sGridNo, pjSoldier->ubDirection, &bDirection ) )
{
if((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true)
if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
{
//Moa: no jumping whith backpack
//sAPCost = GetAPsToJumpFence( pjSoldier, TRUE );
@@ -2963,7 +2979,11 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
if (gGameExternalOptions.fCanClimbOnWalls == TRUE)
{
// No climbing when wearing a backpack!
if((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true)
if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
return;
if ( FindWallJumpDirection( pjSoldier, pjSoldier->sGridNo, pjSoldier->ubDirection, &bDirection ) )
@@ -6991,7 +7011,11 @@ void HandleTBJump( void )
if ( fNearLowerLevel )
{
// CHRISL: Turn off manual jumping while wearing a backpack
if(UsingNewInventorySystem() == true && pjSoldier->inv[BPACKPOCKPOS].exists() == true)
if (UsingNewInventorySystem() == true && pjSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
return;
if ( EnoughPoints( pjSoldier, GetAPsToClimbRoof( pjSoldier, TRUE ), GetBPsToClimbRoof( pjSoldier, TRUE ), FALSE ) )
@@ -7003,7 +7027,11 @@ void HandleTBJump( void )
if ( fNearHeigherLevel )
{
// No climbing when wearing a backpack!
if((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true)
if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
return;
if ( EnoughPoints( pjSoldier, GetAPsToClimbRoof( pjSoldier, FALSE ), GetBPsToClimbRoof( pjSoldier, FALSE ), FALSE ) )
@@ -7015,7 +7043,11 @@ void HandleTBJump( void )
// Jump over fence
if ( FindFenceJumpDirection( pjSoldier, pjSoldier->sGridNo, pjSoldier->ubDirection, &bDirection ) )
{
if((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true)
if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
{
sAPCost = GetAPsToJumpFence( pjSoldier, TRUE );
sBPCost = GetBPsToJumpFence( pjSoldier, TRUE );
@@ -7038,7 +7070,11 @@ void HandleTBJump( void )
if ( FindWallJumpDirection( pjSoldier, pjSoldier->sGridNo, pjSoldier->ubDirection, &bDirection ) )
{
// No climbing when wearing a backpack!
if((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true)
if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
return;
if ( EnoughPoints( pjSoldier, GetAPsToJumpWall( pjSoldier, FALSE ), GetBPsToJumpWall( pjSoldier, FALSE ), FALSE ) )
@@ -7062,7 +7098,11 @@ void HandleTBJumpThroughWindow( void ){
{
if ( FindWindowJumpDirection( pjSoldier, pjSoldier->sGridNo, pjSoldier->ubDirection, &bDirection ) )
{
if((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true)
if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
{
sAPCost = GetAPsToJumpThroughWindows( pjSoldier, TRUE );
sBPCost = GetBPsToJumpThroughWindows( pjSoldier, TRUE );
+4 -1
View File
@@ -579,7 +579,10 @@ BOOLEAN IsActionAffordable(SOLDIERTYPE *pSoldier)
break;
case AI_ACTION_JUMP_WINDOW:
if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true)
if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb )
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
bMinPointsNeeded = GetAPsToJumpThroughWindows( pSoldier, TRUE );
else
bMinPointsNeeded = GetAPsToJumpFence( pSoldier, FALSE );
+4 -1
View File
@@ -2886,7 +2886,10 @@ INT8 FindDirectionForClimbing( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bLevel
else if (bLevel == 1)
{
//CHRISL: If NewInv and wearing a backpack, don't allow climbing
if(UsingNewInventorySystem() == true && pSoldier->inv[BPACKPOCKPOS].exists() == true)
if (UsingNewInventorySystem() == true && pSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
return DIRECTION_IRRELEVANT;
if (gpWorldLevelData[ sGridNo].ubExtFlags[1] & MAPELEMENT_EXT_CLIMBPOINT)
{
+15 -2
View File
@@ -279,7 +279,9 @@ itemStartElementHandle(void *userData, const XML_Char *name, const XML_Char **at
strcmp(name, "ItemChoiceTimeSetting") == 0 ||
strcmp(name, "buddyitem") == 0 ||
strcmp(name, "SleepModifier") == 0 ||
strcmp(name, "usSpotting") == 0))
strcmp(name, "usSpotting") == 0 ||
strcmp(name, "sBackpackWeightModifier") == 0 ||
strcmp(name, "fAllowClimbing") == 0))
{
pData->curElement = ELEMENT_PROPERTY;
//DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("itemStartElementHandle: going into element, name = %s",name) );
@@ -1445,6 +1447,16 @@ itemEndElementHandle(void *userData, const XML_Char *name)
// values between 0 and 100 only
pData->curItem.usSpotting = min(100, max(0, (INT16) atol(pData->szCharData) ) );
}
else if (strcmp(name, "sBackpackWeightModifier") == 0)
{
pData->curElement = ELEMENT;
pData->curItem.sBackpackWeightModifier = (INT16)atol(pData->szCharData);
}
else if (strcmp(name, "fAllowClimbing") == 0)
{
pData->curElement = ELEMENT;
pData->curItem.fAllowClimbing = (BOOLEAN)atol(pData->szCharData);
}
pData->maxReadDepth--;
}
@@ -2088,7 +2100,8 @@ BOOLEAN WriteItemStats()
FilePrintf(hFile,"\t\t<buddyitem>%d</buddyitem>\r\n", Item[cnt].usBuddyItem );
FilePrintf(hFile,"\t\t<SleepModifier>%d</SleepModifier>\r\n", Item[cnt].ubSleepModifier );
FilePrintf(hFile,"\t\t<usSpotting>%d</usSpotting>\r\n", Item[cnt].usSpotting );
FilePrintf(hFile, "\t\t<sBackpackWeightModifier>%d</sBackpackWeightModifier>\r\n", Item[cnt].sBackpackWeightModifier);
FilePrintf(hFile, "\t\t<fAllowClimbing>%d</fAllowClimbing>\r\n", Item[cnt].fAllowClimbing);
FilePrintf(hFile,"\t</ITEM>\r\n");
}
FilePrintf(hFile,"</ITEMLIST>\r\n");