123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- #ifdef PRECOMPILEDHEADERS
- #include "Tactical All.h"
- #else
- #include "Handle UI Plan.h"
- #include "overhead.h"
- #include "Isometric Utils.h"
- #include "pathai.h"
- #include "Handle UI.h"
- #include "points.h"
- #include "weapons.h"
- #include "renderworld.h"
- #include "Animation Control.h"
- #include "message.h"
- #include "soldier create.h"
- #include "interface.h"
- #endif
- UINT8 gubNumUIPlannedMoves = 0;
- SOLDIERTYPE *gpUIPlannedSoldier = NULL;
- SOLDIERTYPE *gpUIStartPlannedSoldier = NULL;
- BOOLEAN gfInUIPlanMode = FALSE;
- void SelectPausedFireAnimation( SOLDIERTYPE *pSoldier );
- BOOLEAN BeginUIPlan( SOLDIERTYPE *pSoldier )
- {
- gubNumUIPlannedMoves = 0;
- gpUIPlannedSoldier = pSoldier;
- gpUIStartPlannedSoldier = pSoldier;
- gfInUIPlanMode = TRUE;
- gfPlotNewMovement = TRUE;
- ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Entering Planning Mode" );
- return( TRUE );
- }
- BOOLEAN AddUIPlan( UINT16 sGridNo, UINT8 ubPlanID )
- {
- SOLDIERTYPE *pPlanSoldier;
- INT16 sXPos, sYPos;
- INT16 sAPCost = 0;
- INT8 bDirection;
- INT32 iLoop;
- SOLDIERCREATE_STRUCT MercCreateStruct;
- UINT8 ubNewIndex;
- // Depeding on stance and direction facing, add guy!
-
- // If we have a planned action here, ignore!
- // If not OK Dest, ignore!
- if ( !NewOKDestination( gpUIPlannedSoldier, sGridNo, FALSE, (INT8)gsInterfaceLevel ) )
- {
- return( FALSE );
- }
- if ( ubPlanID == UIPLAN_ACTION_MOVETO )
- {
- // Calculate cost to move here
- sAPCost = PlotPath( gpUIPlannedSoldier, sGridNo, COPYROUTE, NO_PLOT, TEMPORARY, (UINT16) gpUIPlannedSoldier->usUIMovementMode, NOT_STEALTH, FORWARD, gpUIPlannedSoldier->bActionPoints );
- // Adjust for running if we are not already running
- if ( gpUIPlannedSoldier->usUIMovementMode == RUNNING )
- {
- sAPCost += AP_START_RUN_COST;
- }
- if ( EnoughPoints( gpUIPlannedSoldier, sAPCost, 0, FALSE ) )
- {
- memset( &MercCreateStruct, 0, sizeof( MercCreateStruct ) );
- MercCreateStruct.bTeam = SOLDIER_CREATE_AUTO_TEAM;
- MercCreateStruct.ubProfile = NO_PROFILE;
- MercCreateStruct.fPlayerPlan = TRUE;
- MercCreateStruct.bBodyType = gpUIPlannedSoldier->ubBodyType;
- MercCreateStruct.sInsertionGridNo = sGridNo;
- // Get Grid Corrdinates of mouse
- if ( TacticalCreateSoldier( &MercCreateStruct, &ubNewIndex ) )
- {
- // Get pointer to soldier
- GetSoldier( &pPlanSoldier, (UINT16)ubNewIndex );
- pPlanSoldier->sPlannedTargetX = -1;
- pPlanSoldier->sPlannedTargetY = -1;
- // Compare OPPLISTS!
- // Set ones we don't know about but do now back to old ( ie no new guys )
- for (iLoop = 0; iLoop < MAX_NUM_SOLDIERS; iLoop++ )
- {
- if ( gpUIPlannedSoldier->bOppList[ iLoop ] < 0 )
- {
- pPlanSoldier->bOppList[ iLoop ] = gpUIPlannedSoldier->bOppList[ iLoop ];
- }
- }
- // Get XY from Gridno
- ConvertGridNoToCenterCellXY( sGridNo, &sXPos, &sYPos );
- EVENT_SetSoldierPosition( pPlanSoldier, sXPos, sYPos );
- EVENT_SetSoldierDestination( pPlanSoldier, sGridNo );
- pPlanSoldier->bVisible = 1;
- pPlanSoldier->usUIMovementMode = gpUIPlannedSoldier->usUIMovementMode;
- pPlanSoldier->bActionPoints = gpUIPlannedSoldier->bActionPoints - sAPCost;
- pPlanSoldier->ubPlannedUIAPCost = (UINT8)pPlanSoldier->bActionPoints;
- // Get direction
- bDirection = (INT8)gpUIPlannedSoldier->usPathingData[ gpUIPlannedSoldier->usPathDataSize - 1 ];
- // Set direction
- pPlanSoldier->bDirection = bDirection;
- pPlanSoldier->bDesiredDirection = bDirection;
- // Set walking animation
- ChangeSoldierState( pPlanSoldier, pPlanSoldier->usUIMovementMode, 0, FALSE );
-
- // Change selected soldier
- gusSelectedSoldier = (UINT16)pPlanSoldier->ubID;
- // Change global planned mode to this guy!
- gpUIPlannedSoldier = pPlanSoldier;
- gubNumUIPlannedMoves++;
- gfPlotNewMovement = TRUE;
- ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Adding Merc Move to Plan" );
- }
- }
- else
- {
- ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Merc will not have enough action points" );
- }
- }
- else if ( ubPlanID == UIPLAN_ACTION_FIRE )
- {
- sAPCost = CalcTotalAPsToAttack( gpUIPlannedSoldier, sGridNo, TRUE, (INT8)(gpUIPlannedSoldier->bShownAimTime /2) );
- // Get XY from Gridno
- ConvertGridNoToCenterCellXY( sGridNo, &sXPos, &sYPos );
- // If this is a player guy, show message about no APS
- if ( EnoughPoints( gpUIPlannedSoldier, sAPCost, 0, FALSE ) )
- {
- // CHECK IF WE ARE A PLANNED SOLDIER OR NOT< IF SO< CREATE!
- if ( gpUIPlannedSoldier->ubID < MAX_NUM_SOLDIERS )
- {
- memset( &MercCreateStruct, 0, sizeof( MercCreateStruct ) );
- MercCreateStruct.bTeam = SOLDIER_CREATE_AUTO_TEAM;
- MercCreateStruct.ubProfile = NO_PROFILE;
- MercCreateStruct.fPlayerPlan = TRUE;
- MercCreateStruct.bBodyType = gpUIPlannedSoldier->ubBodyType;
- MercCreateStruct.sInsertionGridNo = sGridNo;
- // Get Grid Corrdinates of mouse
- if ( TacticalCreateSoldier( &MercCreateStruct, &ubNewIndex ) )
- {
- // Get pointer to soldier
- GetSoldier( &pPlanSoldier, (UINT16)ubNewIndex );
- pPlanSoldier->sPlannedTargetX = -1;
- pPlanSoldier->sPlannedTargetY = -1;
- // Compare OPPLISTS!
- // Set ones we don't know about but do now back to old ( ie no new guys )
- for (iLoop = 0; iLoop < MAX_NUM_SOLDIERS; iLoop++ )
- {
- if ( gpUIPlannedSoldier->bOppList[ iLoop ] < 0 )
- {
- pPlanSoldier->bOppList[ iLoop ] = gpUIPlannedSoldier->bOppList[ iLoop ];
- }
- }
- EVENT_SetSoldierPosition( pPlanSoldier, gpUIPlannedSoldier->dXPos, gpUIPlannedSoldier->dYPos );
- EVENT_SetSoldierDestination( pPlanSoldier, gpUIPlannedSoldier->sGridNo );
- pPlanSoldier->bVisible = 1;
- pPlanSoldier->usUIMovementMode = gpUIPlannedSoldier->usUIMovementMode;
- pPlanSoldier->bActionPoints = gpUIPlannedSoldier->bActionPoints - sAPCost;
- pPlanSoldier->ubPlannedUIAPCost = (UINT8)pPlanSoldier->bActionPoints;
- // Get direction
- bDirection = (INT8)gpUIPlannedSoldier->usPathingData[ gpUIPlannedSoldier->usPathDataSize - 1 ];
- // Set direction
- pPlanSoldier->bDirection = bDirection;
- pPlanSoldier->bDesiredDirection = bDirection;
- // Set walking animation
- ChangeSoldierState( pPlanSoldier, pPlanSoldier->usUIMovementMode, 0, FALSE );
-
- // Change selected soldier
- gusSelectedSoldier = (UINT16)pPlanSoldier->ubID;
- // Change global planned mode to this guy!
- gpUIPlannedSoldier = pPlanSoldier;
- gubNumUIPlannedMoves++;
- }
- }
- gpUIPlannedSoldier->bActionPoints = gpUIPlannedSoldier->bActionPoints - sAPCost;
- gpUIPlannedSoldier->ubPlannedUIAPCost = (UINT8)gpUIPlannedSoldier->bActionPoints;
- // Get direction from gridno
- bDirection = (INT8)GetDirectionFromGridNo( sGridNo, gpUIPlannedSoldier );
- // Set direction
- gpUIPlannedSoldier->bDirection = bDirection;
- gpUIPlannedSoldier->bDesiredDirection = bDirection;
- // Set to shooting animation
- SelectPausedFireAnimation( gpUIPlannedSoldier );
- gpUIPlannedSoldier->sPlannedTargetX = sXPos;
- gpUIPlannedSoldier->sPlannedTargetY = sYPos;
- ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Adding Merc Shoot to Plan" );
- }
- else
- {
- ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Merc will not have enough action points" );
- }
- }
- return( TRUE );
- }
- void EndUIPlan( )
- {
- int cnt;
- SOLDIERTYPE *pSoldier;
- // Zero out any planned soldiers
- for( cnt = MAX_NUM_SOLDIERS; cnt < TOTAL_SOLDIERS; cnt++ )
- {
- pSoldier = MercPtrs[ cnt ];
- if ( pSoldier->bActive )
- {
- if ( pSoldier->sPlannedTargetX != -1 )
- {
- SetRenderFlags(RENDER_FLAG_FULL );
- }
- TacticalRemoveSoldier( pSoldier->ubID );
- }
- }
- gfInUIPlanMode = FALSE;
- gusSelectedSoldier = gpUIStartPlannedSoldier->ubID;
- gfPlotNewMovement = TRUE;
- ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Leaving Planning Mode" );
- }
- BOOLEAN InUIPlanMode( )
- {
- return( gfInUIPlanMode );
- }
- void SelectPausedFireAnimation( SOLDIERTYPE *pSoldier )
- {
- // Determine which animation to do...depending on stance and gun in hand...
- switch ( gAnimControl[ pSoldier->usAnimState ].ubEndHeight )
- {
- case ANIM_STAND:
- if ( pSoldier->bDoBurst > 0 )
- {
- ChangeSoldierState( pSoldier, STANDING_BURST, 2 , FALSE );
- }
- else
- {
- ChangeSoldierState( pSoldier, SHOOT_RIFLE_STAND, 2 , FALSE );
- }
- break;
- case ANIM_PRONE:
- ChangeSoldierState( pSoldier, SHOOT_RIFLE_PRONE, 2 , FALSE );
- break;
- case ANIM_CROUCH:
- ChangeSoldierState( pSoldier, SHOOT_RIFLE_CROUCH, 2 , FALSE );
- break;
- }
- }
|