Home » MODDING HQ 1.13 » v1.13 Idea Incubation Lab  » A Small Compilation of New Features
Re: A Small Compilation of New Features[message #316949] Wed, 03 April 2013 00:24 Go to previous messageGo to previous message
merc05 is currently offline merc05

 
Messages:90
Registered:January 2013
At the end of Handle UI.cpp file is a block called BOOLEAN IsValidJumpLocation( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fCheckForPath )

There is a line at 6924 and another at 7057 that checks whether Shift+Ctrl are pressed.

This is the code from my disk where I have changed this to Alt (original code after "//")

// This function contains the logic for allowing the player
// to jump over people.
BOOLEAN IsValidJumpLocation( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fCheckForPath )
{
	// SANDRO: been here, did mess
	INT32 sFourGrids[4], sDistance=0, sSpot, sInBetween, sInBetween2, iDoorGridNo;
	static const UINT8 sDirs[4] = { NORTH, EAST, SOUTH, WEST };
	//INT32 cnt;
	UINT8	ubGuyThere, ubMovementCost, ubDirection;
	INT8 bTileHeight = 0;

	// SANDRO: commented out to allow jumping even in cases we could get to the destination normally
	// First check that action point cost is zero so far
	// ie: NO PATH!
	/*if ( gsCurrentActionPoints != 0 && fCheckForPath )
	{
		return( FALSE );
	}*/
	
	// Loop through positions...
	for (INT8 cnt = 0; cnt < 4; cnt++)
	{
		// MOVE OUT TWO DIRECTIONS
		sInBetween = NewGridNo( sGridNo, DirectionInc( sDirs[ cnt ] ) );

		// SANDRO: moved this someplace else and made it more fluid
		// ATE: Check our movement costs for going through walls!
		/*ubMovementCost = gubWorldMovementCosts[ sIntSpot ][ sDirs[ cnt ] ][ pSoldier->pathing.bLevel ];
		if ( IS_TRAVELCOST_DOOR( ubMovementCost ) )
		{
			ubMovementCost = DoorTravelCost( pSoldier, sIntSpot, ubMovementCost, (BOOLEAN) (pSoldier->bTeam == gbPlayerNum), &iDoorGridNo );
		}*/

		// If we have hit an obstacle, STOP HERE
		//if ( ubMovementCost >= TRAVELCOST_BLOCKED )
		//{
		//	// no good, continue
		//	continue;
		//}


		// TWICE AS FAR!
		sFourGrids[cnt] = sSpot = NewGridNo( sInBetween, DirectionInc( sDirs[ cnt ] ) );

		// Is the soldier we're looking at here?
		ubGuyThere = WhoIsThere2( sSpot, pSoldier->pathing.bLevel );

		// Alright folks, here we are!
		if ( ubGuyThere == pSoldier->ubID )
		{
			// Double check OK destination......
			if ( NewOKDestination( pSoldier, sGridNo, TRUE, (INT8)gsInterfaceLevel ) && IsLocationSittable( sGridNo, pSoldier->pathing.bLevel ) )
			{
				// If the soldier in the middle of doing stuff?
				if ( !pSoldier->flags.fTurningUntilDone )
				{
					// OK, NOW check if there is a guy in between us
					//
					// SANDRO: made this a bit different - if we hold down the shift key, and pointing at a spot 2 tiles away, we check if jumping 
					// there is possible for all cases, and if it is, then we juuuuumpppp!
					// So we don't care if there is a guy on the ground there, and the cursor wont appear atutomatically anymore
					//
					//ubGuyThere = WhoIsThere2( sIntSpot, pSoldier->pathing.bLevel );
					// Is there a guy and is he prone?
					//if ( ubGuyThere != NOBODY && ubGuyThere != pSoldier->ubID && gAnimControl[ MercPtrs[ ubGuyThere ]->usAnimState ].ubHeight == ANIM_PRONE )
					//{
					//	// It's a GO!
					//	return( TRUE );
					//}
					//else

					// Can't jump from a water tile (but we can jumpt TO a water tile)
					if ( pSoldier->MercInWater() )
					{
						return( FALSE );
					}

					// check for cliffs and similar oddities
					if ( gpWorldLevelData[ sGridNo ].sHeight != gpWorldLevelData[ sSpot ].sHeight )
					{
						return( FALSE );
					}

					// If there's a guy here, and he's not prone, we can't jump over him (maybe the way we hop over fence when he's crouched? lol)
					ubGuyThere = WhoIsThere2( sInBetween, pSoldier->pathing.bLevel );
					if ( ubGuyThere != NOBODY && ubGuyThere != pSoldier->ubID )
					{
						if ( gAnimControl[ MercPtrs[ ubGuyThere ]->usAnimState ].ubHeight != ANIM_PRONE )
						{
							return( FALSE );
						}
						else if ( gsCurrentActionPoints == 0 || !fCheckForPath )
						{
							return( TRUE );
						}
					}

					// Get the height of stuff on the tile, we can only jump over low obstacles like this
					bTileHeight = GetTallestStructureHeight( sInBetween, pSoldier->pathing.bLevel );
					if ( bTileHeight > 0 && !IsLocationSittableExcludingPeople( sInBetween, pSoldier->pathing.bLevel ) && !( pSoldier->pathing.bLevel && FlatRoofAboveGridNo( sInBetween ) )) 
					{
						return( FALSE );
					}

					// Check again for these structures as they may have odd height preset
					if (( FindStructure( sInBetween, STRUCTURE_TREE ) != NULL || FindStructure( sInBetween, STRUCTURE_FENCE ) != NULL ||
						 FindStructure( sInBetween, STRUCTURE_WIREFENCE ) != NULL || FindStructure( sInBetween, STRUCTURE_VEHICLE ) != NULL ||
						 FindStructure( sInBetween, STRUCTURE_CAVEWALL ) != NULL ) && !IsLocationSittableExcludingPeople( sInBetween, pSoldier->pathing.bLevel ))
					{	
						return( FALSE );
					}

					// Now check for walls between the tiles
					// Between our tile and the middle tile...
					ubDirection = GetDirectionToGridNoFromGridNo( sInBetween, pSoldier->sGridNo );
					ubMovementCost = gubWorldMovementCosts[ pSoldier->sGridNo ][ ubDirection ][ pSoldier->pathing.bLevel ];
					if ( IS_TRAVELCOST_DOOR( ubMovementCost ) )
					{
						ubMovementCost = DoorTravelCost( pSoldier, pSoldier->sGridNo, ubMovementCost, (BOOLEAN) (pSoldier->bTeam == gbPlayerNum), &iDoorGridNo );
					}
					if ( ubMovementCost >= TRAVELCOST_BLOCKED )
					{
						return( FALSE );
					}
					// Between destination tile and the middle tile...
					ubDirection = GetDirectionToGridNoFromGridNo( sInBetween, sGridNo );
					ubMovementCost = gubWorldMovementCosts[ sGridNo ][ ubDirection ][ pSoldier->pathing.bLevel ];
					if ( IS_TRAVELCOST_DOOR( ubMovementCost ) )
					{
						ubMovementCost = DoorTravelCost( pSoldier, sGridNo, ubMovementCost, (BOOLEAN) (pSoldier->bTeam == gbPlayerNum), &iDoorGridNo );
					}
					if ( ubMovementCost >= TRAVELCOST_BLOCKED )
					{
						return( FALSE );
					}
						
					if( !(_KeyDown( SHIFT ) && _KeyDown( ALT )) ) //if( !(_KeyDown( SHIFT ) && _KeyDown( CTRL )) )
					{
						return( FALSE );
					}

					// If we got here, we are good to go
					return ( TRUE );
				}
			}
		}
		// Attempt to long jump
		else
		{
			// 3 TILES FAR!
			sInBetween2 = sSpot; 
			sSpot = NewGridNo( sInBetween2, DirectionInc( sDirs[ cnt ] ) );

			// Is the soldier we're looking at here?
			ubGuyThere = WhoIsThere2( sSpot, pSoldier->pathing.bLevel );

			// Alright folks, here we are!
			if ( ubGuyThere == pSoldier->ubID )
			{
				// Double check OK destination......
				if ( NewOKDestination( pSoldier, sGridNo, TRUE, (INT8)gsInterfaceLevel ) && IsLocationSittable( sGridNo, pSoldier->pathing.bLevel ) )
				{
					// If the soldier in the middle of doing stuff?
					if ( !pSoldier->flags.fTurningUntilDone )
					{			
						// Can't jump from a water tile (but we can jumpt TO a water tile)
						if ( pSoldier->MercInWater() )
						{
							return( FALSE );
						}

						// This ain't gonna happen with backpack
						if((UsingNewInventorySystem() == true) && FindBackpackOnSoldier( pSoldier ) != ITEM_NOT_FOUND )
						{
							return( FALSE );
						}

						// check for cliffs and similar oddities
						if ( gpWorldLevelData[ sGridNo ].sHeight != gpWorldLevelData[ sSpot ].sHeight )
						{
							return( FALSE );
						}

						// If there's a guy on any of the two middle tiles, and he's not prone, we can't jump over him
						ubGuyThere = WhoIsThere2( sInBetween, pSoldier->pathing.bLevel );
						if ( ubGuyThere != NOBODY && ubGuyThere != pSoldier->ubID && gAnimControl[ MercPtrs[ ubGuyThere ]->usAnimState ].ubHeight != ANIM_PRONE )
						{
							return( FALSE );
						}
						ubGuyThere = WhoIsThere2( sInBetween2, pSoldier->pathing.bLevel );
						if ( ubGuyThere != NOBODY && ubGuyThere != pSoldier->ubID && gAnimControl[ MercPtrs[ ubGuyThere ]->usAnimState ].ubHeight != ANIM_PRONE )
						{
							return( FALSE );
						}

						// Get the height of stuff on both middle tiles, we can only jump over low obstacles
						bTileHeight = GetTallestStructureHeight( sInBetween, pSoldier->pathing.bLevel );
						if ( bTileHeight > 0 && !IsLocationSittableExcludingPeople( sInBetween, pSoldier->pathing.bLevel ) && !( pSoldier->pathing.bLevel && FlatRoofAboveGridNo( sInBetween ) )) 
						{
							return( FALSE );
						}
						bTileHeight = GetTallestStructureHeight( sInBetween2, pSoldier->pathing.bLevel );
						if ( bTileHeight > 0 && !IsLocationSittableExcludingPeople( sInBetween2, pSoldier->pathing.bLevel ) && !( pSoldier->pathing.bLevel && FlatRoofAboveGridNo( sInBetween2 ) )) 
						{
							return( FALSE );
						}

						// Check again for these structures as they may have odd height preset
						if (( FindStructure( sInBetween, STRUCTURE_TREE ) != NULL || FindStructure( sInBetween, STRUCTURE_FENCE ) != NULL ||
							 FindStructure( sInBetween, STRUCTURE_WIREFENCE ) != NULL || FindStructure( sInBetween, STRUCTURE_VEHICLE ) != NULL ||
							 FindStructure( sInBetween, STRUCTURE_CAVEWALL ) != NULL ) && !IsLocationSittableExcludingPeople( sInBetween, pSoldier->pathing.bLevel ))
						{	
							return( FALSE );
						}
						if (( FindStructure( sInBetween2, STRUCTURE_TREE ) != NULL || FindStructure( sInBetween2, STRUCTURE_FENCE ) != NULL ||
							 FindStructure( sInBetween2, STRUCTURE_WIREFENCE ) != NULL || FindStructure( sInBetween2, STRUCTURE_VEHICLE ) != NULL ||
							 FindStructure( sInBetween2, STRUCTURE_CAVEWALL ) != NULL ) && !IsLocationSittableExcludingPeople( sInBetween2, pSoldier->pathing.bLevel ))
						{	
							return( FALSE );
						}

						// Now check for walls between the tiles
						// Between our tile and the middle tile next to us...
						ubDirection = GetDirectionToGridNoFromGridNo( sInBetween2, pSoldier->sGridNo );
						ubMovementCost = gubWorldMovementCosts[ pSoldier->sGridNo ][ ubDirection ][ pSoldier->pathing.bLevel ];
						if ( IS_TRAVELCOST_DOOR( ubMovementCost ) )
						{
							ubMovementCost = DoorTravelCost( pSoldier, pSoldier->sGridNo, ubMovementCost, (BOOLEAN) (pSoldier->bTeam == gbPlayerNum), &iDoorGridNo );
						}
						if ( ubMovementCost >= TRAVELCOST_BLOCKED )
						{
							return( FALSE );
						}
						// Between destination tile and the middle tile next to it...
						ubDirection = GetDirectionToGridNoFromGridNo( sInBetween, sGridNo );
						ubMovementCost = gubWorldMovementCosts[ sGridNo ][ ubDirection ][ pSoldier->pathing.bLevel ];
						if ( IS_TRAVELCOST_DOOR( ubMovementCost ) )
						{
							ubMovementCost = DoorTravelCost( pSoldier, sGridNo, ubMovementCost, (BOOLEAN) (pSoldier->bTeam == gbPlayerNum), &iDoorGridNo );
						}
						if ( ubMovementCost >= TRAVELCOST_BLOCKED )
						{
							return( FALSE );
						}
						// Now we need to check if there is not a wall between the two middle tiles
						ubDirection = GetDirectionToGridNoFromGridNo( sInBetween2, sInBetween );
						switch (ubDirection)
						{
						case NORTH: 
							if ( WallOrClosedDoorExistsOfTopLeftOrientation( sInBetween ) )
								return( FALSE );
							break;
						case EAST: 
							if ( WallOrClosedDoorExistsOfTopRightOrientation( sInBetween2 ) )
								return( FALSE );
							break;
						case SOUTH:
							if ( WallOrClosedDoorExistsOfTopLeftOrientation( sInBetween2 ) )
								return( FALSE );
							break;
						case WEST:
							if ( WallOrClosedDoorExistsOfTopRightOrientation( sInBetween ) )
								return( FALSE );
							break;	
						default:
							return( FALSE );
							break;							
						}
						
						if( !(_KeyDown( SHIFT ) && _KeyDown( ALT )) ) //if( !(_KeyDown( SHIFT ) && _KeyDown( CTRL )) )
						{
							return( FALSE );
						}						

						// If we got here, we are good to go
						return ( TRUE );
					}
				}
			}
		}
	}

	return( FALSE );
}

Report message to a moderator

Corporal 1st Class
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: goc_man Single Click Installers
Next Topic: [Linux] ja2 1.13 linux port (alpha release)
Goto Forum:
  


Current Time: Sun Feb 16 01:20:04 GMT+2 2025

Total time taken to generate the page: 0.03760 seconds