diff --git a/NewGameSettings.cpp b/NewGameSettings.cpp index 238f4625c..7f310c74b 100644 --- a/NewGameSettings.cpp +++ b/NewGameSettings.cpp @@ -7,14 +7,35 @@ #define GAME_INI_FILE "\\Ja2.ini" -BOOLEAN gfStretch = FALSE; -BOOLEAN gfStretchWinGDI = FALSE; -BOOLEAN gfVSync = FALSE; +#define SET_SYSTEM "JA2 System Settings" +#define SET_RESOLUTION "JA2 Screen Resolution Settings" +#define SET_RAIN "JA2 Rain Settings" +#define SET_THUNDER "JA2 Thunder Settings" +#define SET_TURN_SPEED "JA2 Turnbased Animation Speed Settings" +#define SET_STRATEGIC "JA2 Strategic Settings" +#define SET_SPECIAL "JA2 Special Settings" +#define SET_TACTICAL "JA2 Tactical Settings" +#define SET_TACTICAL_AI "JA2 Tactical AI Settings" +#define SET_GRAPHIC "JA2 Graphic Settings" +#define SET_GAMEPLAY "JA2 Gameplay Settings" + + +UINT8 gubDeadLockDelay = 15; +UINT8 ubStraightSightRange = 13; + +BOOLEAN gfVSync = FALSE; BOOLEAN gfAllowRain = FALSE; UINT16 gusRainChancePerDay = 100, gusRainMinLength = 60, gusRainMaxLength = 180; + +extern UINT8 gubPlayerTurnSpeedUpFactor; +extern UINT8 gubEnemyTurnSpeedUpFactor; +extern UINT8 gubCreatureTurnSpeedUpFactor; +extern UINT8 gubMilitiaTurnSpeedUpFactor; +extern UINT8 gubCivTurnSpeedUpFactor; + extern UINT32 guiMinLightningInterval; extern UINT32 guiMaxLightningInterval; extern UINT32 guiMinDLInterval; @@ -24,6 +45,14 @@ extern UINT32 guiChanceToDoLightningBetweenTurns; extern UINT32 guiMaxRainDrops; +BOOLEAN gfEnableEmergencyButton_SkipStrategicEvents = FALSE; +BOOLEAN gfAllowMilitiaGroups = TRUE; +BOOLEAN gfAllowReinforcments = TRUE; +BOOLEAN gfAllowReinforcmentsOnlyInCity = FALSE; +UINT32 guiBaseQueenPoolIncrement = 60; + +BOOLEAN fAllowTacticalMilitiaCommand = TRUE; + typedef struct { CHAR8* strParamName; @@ -32,8 +61,6 @@ typedef struct UINT8 ubVarType; }TSetting; -#define SET_RAIN "JA2 Rain Settings" -#define SET_THUNDER "JA2 Thunder Settings" enum { @@ -46,8 +73,36 @@ enum VT_BOOLEAN }; -TSetting gpSettings[] = { +TSetting gpSettings[] = +{ + {"fVSync", SET_RESOLUTION, &gfVSync, VT_BOOLEAN}, + {"PlayerTurnSpeedUpFactor", SET_TURN_SPEED, (LPVOID)&gubPlayerTurnSpeedUpFactor, VT_UINT8}, + {"EnemyTurnSpeedUpFactor", SET_TURN_SPEED, (LPVOID)&gubEnemyTurnSpeedUpFactor, VT_UINT8}, + {"CreatureTurnSpeedUpFactor", SET_TURN_SPEED, (LPVOID)&gubCreatureTurnSpeedUpFactor, VT_UINT8}, + {"MilitiaTurnSpeedUpFactor", SET_TURN_SPEED, (LPVOID)&gubMilitiaTurnSpeedUpFactor, VT_UINT8}, + {"CivTurnSpeedUpFactor", SET_TURN_SPEED, (LPVOID)&gubCivTurnSpeedUpFactor, VT_UINT8}, + + // Militia Settings + {"AllowTacticalMilitiaCommand", SET_TACTICAL, &fAllowTacticalMilitiaCommand, VT_BOOLEAN}, + + {"AllowMilitiaMobileGroups", SET_GAMEPLAY, &gfAllowMilitiaGroups, VT_BOOLEAN}, + {"AllowReinforcments", SET_GAMEPLAY, &gfAllowReinforcments, VT_BOOLEAN}, + {"AllowReinforcmentsOnlyInCities", SET_GAMEPLAY, &gfAllowReinforcmentsOnlyInCity, VT_BOOLEAN}, + {"QueenPoolIncrementPerDifficultyLevel", SET_GAMEPLAY, &guiBaseQueenPoolIncrement, VT_UINT32}, + + + //Sight range + {"BaseSightRange", SET_TACTICAL, &ubStraightSightRange, VT_UINT8}, + + + // Maximal search distance for grenades + //{"MaxTossSearchDist", SET_TACTICAL_AI, &guiMaxTossSearchDist, VT_UINT32}, + + //{"fEnableEmergencyButton_NumLock_ToSkipStrategicEvents", SET_SPECIAL, &gfEnableEmergencyButton_SkipStrategicEvents, VT_BOOLEAN}, + + + // Rain settings {"ALLOW_RAIN", SET_RAIN, &gfAllowRain, VT_BOOLEAN}, {"RAIN_CHANCE_PER_DAY", SET_RAIN, &gusRainChancePerDay, VT_UINT16}, diff --git a/NewGameSettings.h b/NewGameSettings.h index e8845b597..9e184a398 100644 --- a/NewGameSettings.h +++ b/NewGameSettings.h @@ -1,10 +1,16 @@ #ifndef ___NEW_GAME_SETTINGS___ #define ___NEW_GAME_SETTINGS___ -extern BOOLEAN gfUseABResources; -extern BOOLEAN gfEnableEmergencyButton_SkipStrategicEvents; -extern UINT32 guiMaxTossSearchDist; -extern BOOLEAN gfShowItemShadow; +//extern BOOLEAN gfUseABResources; +//extern BOOLEAN gfEnableEmergencyButton_SkipStrategicEvents; +//extern UINT32 guiMaxTossSearchDist; +//extern BOOLEAN gfShowItemShadow; + +extern BOOLEAN gfAllowMilitiaGroups; +extern BOOLEAN gfAllowReinforcments; +extern BOOLEAN gfAllowReinforcmentsOnlyInCity; +extern UINT32 guiBaseQueenPoolIncrement; +extern UINT8 ubStraightSightRange; void NSSaveSettings(); void NSLoadSettings(); diff --git a/Strategic/Map Screen Interface.cpp b/Strategic/Map Screen Interface.cpp index 3c920b1bc..b2dbb82fa 100644 --- a/Strategic/Map Screen Interface.cpp +++ b/Strategic/Map Screen Interface.cpp @@ -290,6 +290,8 @@ BOOLEAN fShowAttributeMenu = FALSE; BOOLEAN fShowSquadMenu = FALSE; BOOLEAN fShowContractMenu = FALSE; BOOLEAN fShowRemoveMenu = FALSE; +BOOLEAN fShowMilitiaControlMenu = FALSE; //lal +//BOOLEAN fShowTalkToAllMenu = FALSE;//lal BOOLEAN fRebuildMoveBox = FALSE; @@ -306,8 +308,17 @@ SGPPoint VehiclePosition={160,150}; SGPPoint RepairPosition={160,150}; SGPRect RepairDimensions={0,0,80,80}; -SGPRect AssignmentDimensions = { 0,0, 100, 95}; +//lal +SGPPoint MilitiaControlPosition={120,150}; +SGPRect MilitiaControlDimensions={0,0,100,95}; + +//SGPPoint TalkToAllPosition={160,150}; +//SGPRect TalkToAllDimensions={0,0,100,95}; +//lal + SGPPoint AssignmentPosition = { 120, 150 }; +SGPRect AssignmentDimensions = { 0,0, 100, 95}; + SGPPoint SquadPosition ={ 160, 150 }; SGPRect SquadDimensions ={ 0, 0, 140, 60 }; @@ -317,6 +328,8 @@ SGPPoint OrigSquadPosition ={ 160, 150 }; SGPPoint OrigAssignmentPosition = { 120, 150 }; SGPPoint OrigTrainPosition={160,150}; SGPPoint OrigVehiclePosition={160,150}; +SGPPoint OrigMilitiaControlPosition = { 120, 150 }; //lal +//SGPPoint OrigTalkToAllPosition = { 160, 150 }; //extern BOOLEAN fMapExitDueToMessageBox; @@ -2205,6 +2218,65 @@ void UpdateMapScreenAssignmentPositions( void ) } +//lal +void UpdateMapScreenMilitiaControlPositions( void ) +{ + // set the position of the pop up boxes + SGPPoint pPoint; + + if( guiCurrentScreen != MAP_SCREEN ) + { + return; + } + + if( bSelectedAssignChar == -1 ) + { + if( gfPreBattleInterfaceActive == FALSE ) + { + giBoxY = 0; + } + return; + } + + if( gCharactersList[ bSelectedAssignChar ].fValid == FALSE ) + { + if( gfPreBattleInterfaceActive == FALSE ) + { + giBoxY = 0; + } + return; + } + + if( gfPreBattleInterfaceActive ) + { + // do nothing + } + else + { + giBoxY = ( Y_START + ( bSelectedAssignChar ) * ( Y_SIZE + 2 ) ); + } + + MilitiaControlPosition.iY = giBoxY; + + //TalkToAllPosition.iY = MilitiaControlPosition.iY + ( GetFontHeight( MAP_SCREEN_FONT ) + 2 )* MILCON_MENU_ALL; + + + + if( fShowMilitiaControlMenu ) + { + GetBoxPosition( ghMilitiaControlBox, &pPoint); + pPoint.iY = giBoxY; + + SetBoxPosition( ghMilitiaControlBox, pPoint ); + } + + return; +} +//lal + + + + void RandomMercInGroupSaysQuote( GROUP *pGroup, UINT16 usQuoteNum ) { diff --git a/Strategic/Map Screen Interface.h b/Strategic/Map Screen Interface.h index dff205d99..eb28320b3 100644 --- a/Strategic/Map Screen Interface.h +++ b/Strategic/Map Screen Interface.h @@ -52,6 +52,35 @@ typedef struct FASTHELPREGION { #define MAP_START_KEYRING_Y 107 #define Y_SIZE GetFontHeight(MAP_SCREEN_FONT) +//lal +// militia control menu +enum{ + MILCON_MENU_ATTACK, + MILCON_MENU_HOLD, + MILCON_MENU_RETREAT, + MILCON_MENU_COMETOME, + MILCON_MENU_GETDOWN, + MILCON_MENU_TAKE_COVER, + MILCON_MENU_ALL_ATTACK, + MILCON_MENU_ALL_HOLD, + MILCON_MENU_ALL_RETREAT, + MILCON_MENU_ALL_COMETOME, + MILCON_MENU_ALL_GETDOWN, + MILCON_MENU_ALL_TAKE_COVER, + MILCON_MENU_ALL_TAKE_ITEMS, + MILCON_MENU_CANCEL, + MAX_MILCON_STRING_COUNT, +}; + +//enum{ +// TTALL_MENU_ATTACK, +// TTALL_MENU_HOLD, +// TTALL_MENU_RETREAT, +// TTALL_MENU_COMETOME, +// TTALL_MENU_GETDOWN, +// TTALL_MENU_CANCEL, +// MAX_TTALL_STRING_COUNT, +//}; // attribute menu defines (must match NUM_TRAINABLE_STATS defines, and pAttributeMenuStrings ) enum { @@ -212,6 +241,8 @@ extern BOOLEAN fShowAttributeMenu; extern BOOLEAN fShowSquadMenu ; extern BOOLEAN fShowContractMenu ; extern BOOLEAN fShowRemoveMenu ; +extern BOOLEAN fShowMilitiaControlMenu ; //lal +//extern BOOLEAN fShowTalkToAllMenu ; extern BOOLEAN fFirstTimeInMapScreen; extern BOOLEAN fLockOutMapScreenInterface; @@ -261,12 +292,20 @@ extern SGPRect SquadDimensions ; extern SGPPoint RepairPosition; extern SGPRect RepairDimensions; +extern SGPPoint MilitiaControlPosition; //lal +extern SGPRect MilitiaControlDimensions; + +//extern SGPPoint TalkToAllPosition; +//extern SGPRect TalkToAllDimensions; + extern SGPPoint OrigContractPosition; extern SGPPoint OrigAttributePosition; extern SGPPoint OrigSquadPosition ; extern SGPPoint OrigAssignmentPosition ; extern SGPPoint OrigTrainPosition; extern SGPPoint OrigVehiclePosition; +extern SGPPoint OrigMilitiaControlPosition ; //lal +//extern SGPPoint OrigTalkToAllPosition ; // disble team info panel due to showing of battle roster extern BOOLEAN fDisableDueToBattleRoster; @@ -433,6 +472,7 @@ void RenderMapRegionBackground( void ); // update mapscreen assignment positions void UpdateMapScreenAssignmentPositions( void ); +void UpdateMapScreenMilitiaControlPositions( void ); // get the umber of valid mercs in the mapscreen character list INT32 GetNumberOfPeopleInCharacterList( void ); diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 16f9bb29a..b6f082d19 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -862,6 +862,7 @@ void CreateTrainingBox( void ); void CreateMercRemoveAssignBox( void ); void DetermineWhichAssignmentMenusCanBeShown( void ); +void DetermineWhichMilitiaControlMenusCanBeShown( void ); //lal void DetermineIfContractMenuCanBeShown( void ); void ContractRegionBtnCallback( MOUSE_REGION * pRegion, INT32 iReason ); @@ -3697,6 +3698,7 @@ UINT32 MapScreenHandle(void) // check which menus can be shown right now DetermineWhichAssignmentMenusCanBeShown( ); + DetermineWhichMilitiaControlMenusCanBeShown( ); //lal // determine if contract menu can be shown DetermineIfContractMenuCanBeShown( ); @@ -6011,6 +6013,7 @@ void EndMapScreen( BOOLEAN fDuringFade ) // clear out mouse regions for pop up boxes DetermineWhichAssignmentMenusCanBeShown( ); + DetermineWhichMilitiaControlMenusCanBeShown( ); //lal sSelectedMilitiaTown = 0; CreateDestroyMilitiaPopUPRegions( ); CreateDestroyMilitiaSectorButtons( ); @@ -6024,6 +6027,7 @@ void EndMapScreen( BOOLEAN fDuringFade ) ghContractBox = -1; CreateDestroyAssignmentPopUpBoxes( ); + CreateDestroyMilitiaControlPopUpBoxes( ); //lal // shutdown movement box if ( fShowMapScreenMovementList ) diff --git a/Tactical/Handle UI.cpp b/Tactical/Handle UI.cpp index 90551f6e5..9e69eb288 100644 --- a/Tactical/Handle UI.cpp +++ b/Tactical/Handle UI.cpp @@ -5520,6 +5520,7 @@ BOOLEAN HandleTalkInit( ) INT16 sDistVisible; INT16 sActionGridNo; UINT8 ubDirection; + UINT8 commandRange; //lal // Get soldier if ( !GetSoldier( &pSoldier, gusSelectedSoldier ) ) @@ -5535,189 +5536,203 @@ BOOLEAN HandleTalkInit( ) // Check if there is a guy here to talk to! if ( gfUIFullTargetFound ) { - // Is he a valid NPC? - if ( IsValidTalkableNPC( (UINT8)gusUIFullTargetID, FALSE, TRUE , FALSE ) ) - { - GetSoldier( &pTSoldier, gusUIFullTargetID ); + // Is he a valid NPC? + if ( IsValidTalkableNPC( (UINT8)gusUIFullTargetID, FALSE, TRUE , FALSE ) ) + { + GetSoldier( &pTSoldier, gusUIFullTargetID ); - if ( pTSoldier->ubID != pSoldier->ubID ) - { - //ATE: Check if we have good LOS - // is he close enough to see that gridno if he turns his head? + if ( pTSoldier->ubID != pSoldier->ubID ) + { + if ( !(( pTSoldier->bTeam == MILITIA_TEAM ) && ( CheckIfRadioIsEquipped() )) ) //lal + { + //ATE: Check if we have good LOS + // is he close enough to see that gridno if he turns his head? sDistVisible = DistanceVisible( pSoldier, DIRECTION_IRRELEVANT, DIRECTION_IRRELEVANT, pTSoldier->sGridNo, pTSoldier->bLevel, pTSoldier ); - // Check LOS! - if ( !SoldierTo3DLocationLineOfSightTest( pSoldier, pTSoldier->sGridNo, pTSoldier->bLevel, 3, (UINT8) sDistVisible, TRUE ) ) - { - if ( pTSoldier->ubProfile != NO_PROFILE ) - { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ NO_LOS_TO_TALK_TARGET ], pSoldier->name, pTSoldier->name ); - } - else - { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, gzLateLocalizedString[ 45 ], pSoldier->name ); - } - return( FALSE ); - } - } + // Check LOS! + if ( !SoldierTo3DLocationLineOfSightTest( pSoldier, pTSoldier->sGridNo, pTSoldier->bLevel, 3, (UINT8) sDistVisible, TRUE ) ) + { + if ( pTSoldier->ubProfile != NO_PROFILE ) + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ NO_LOS_TO_TALK_TARGET ], pSoldier->name, pTSoldier->name ); + } + else + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, gzLateLocalizedString[ 45 ], pSoldier->name ); + } + return( FALSE ); + } + } + } - if ( pTSoldier->bCollapsed ) - { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, gzLateLocalizedString[ 21 ], pTSoldier->name ); - return( FALSE ); - } + if ( pTSoldier->bCollapsed ) + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, gzLateLocalizedString[ 21 ], pTSoldier->name ); + return( FALSE ); + } - // If Q on, turn off..... - if ( guiCurrentScreen == DEBUG_SCREEN ) - { - gfExitDebugScreen = TRUE; + // If Q on, turn off..... + if ( guiCurrentScreen == DEBUG_SCREEN ) + { + gfExitDebugScreen = TRUE; + } + + // ATE: if our own guy... + if ( pTSoldier->bTeam == gbPlayerNum && !AM_AN_EPC( pTSoldier ) ) + { + if ( pTSoldier->ubProfile == DIMITRI ) + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, gzLateLocalizedString[ 32 ], pTSoldier->name ); + return( FALSE ); } - // ATE: if our own guy... - if ( pTSoldier->bTeam == gbPlayerNum && !AM_AN_EPC( pTSoldier ) ) + // Randomize quote to use.... + + // If buddy had a social trait... + if ( gMercProfiles[ pTSoldier->ubProfile ].bAttitude != ATT_NORMAL ) { - if ( pTSoldier->ubProfile == DIMITRI ) - { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, gzLateLocalizedString[ 32 ], pTSoldier->name ); - return( FALSE ); - } + ubDiceRoll = (UINT8)Random( 3 ); + } + else + { + ubDiceRoll = (UINT8)Random( 2 ); + } - // Randomize quote to use.... + // If we are a PC, only use 0 + if ( pTSoldier->ubWhatKindOfMercAmI == MERC_TYPE__PLAYER_CHARACTER ) + { + ubDiceRoll = 0; + } - // If buddy had a social trait... - if ( gMercProfiles[ pTSoldier->ubProfile ].bAttitude != ATT_NORMAL ) + switch( ubDiceRoll ) + { + case 0: + + ubQuoteNum = QUOTE_NEGATIVE_COMPANY; + break; + + case 1: + + if ( QuoteExp_PassingDislike[ pTSoldier->ubProfile ] ) { - ubDiceRoll = (UINT8)Random( 3 ); + ubQuoteNum = QUOTE_PASSING_DISLIKE; } else { - ubDiceRoll = (UINT8)Random( 2 ); + ubQuoteNum = QUOTE_NEGATIVE_COMPANY; } + break; - // If we are a PC, only use 0 - if ( pTSoldier->ubWhatKindOfMercAmI == MERC_TYPE__PLAYER_CHARACTER ) - { - ubDiceRoll = 0; - } - - switch( ubDiceRoll ) - { - case 0: + case 2: - ubQuoteNum = QUOTE_NEGATIVE_COMPANY; - break; + ubQuoteNum = QUOTE_SOCIAL_TRAIT; + break; - case 1: + default: - if ( QuoteExp_PassingDislike[ pTSoldier->ubProfile ] ) - { - ubQuoteNum = QUOTE_PASSING_DISLIKE; - } - else - { - ubQuoteNum = QUOTE_NEGATIVE_COMPANY; - } - break; - - case 2: - - ubQuoteNum = QUOTE_SOCIAL_TRAIT; - break; - - default: - - ubQuoteNum = QUOTE_NEGATIVE_COMPANY; - break; - } - - if ( pTSoldier->ubProfile == IRA ) - { - ubQuoteNum = QUOTE_PASSING_DISLIKE; - } - - TacticalCharacterDialogue( pTSoldier, ubQuoteNum ); - - return( FALSE ); + ubQuoteNum = QUOTE_NEGATIVE_COMPANY; + break; } - // Check distance - uiRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, usMapPos ); - - // Double check path - if ( GetCivType( pTSoldier ) != CIV_TYPE_NA ) + if ( pTSoldier->ubProfile == IRA ) { - // ATE: If one is already active, just remove it! - if ( ShutDownQuoteBoxIfActive( ) ) - { - return( FALSE ); - } + ubQuoteNum = QUOTE_PASSING_DISLIKE; } - if ( uiRange > NPC_TALK_RADIUS ) - { - // First get an adjacent gridno.... - sActionGridNo = FindAdjacentGridEx( pSoldier, pTSoldier->sGridNo, &ubDirection, NULL, FALSE, TRUE ); - - if ( sActionGridNo == -1 ) - { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ NO_PATH ] ); - return( FALSE ); - } - - if ( UIPlotPath( pSoldier, sActionGridNo, NO_COPYROUTE, FALSE, TEMPORARY, (UINT16)pSoldier->usUIMovementMode, NOT_STEALTH, FORWARD, pSoldier->bActionPoints ) == 0 ) - { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ NO_PATH ] ); - return( FALSE ); - } + TacticalCharacterDialogue( pTSoldier, ubQuoteNum ); - // Walk up and talk to buddy.... - gfNPCCircularDistLimit = TRUE; - sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, pSoldier->usUIMovementMode, pTSoldier->sGridNo, (NPC_TALK_RADIUS-1), &ubNewDirection, TRUE ); - gfNPCCircularDistLimit = FALSE; + return( FALSE ); + } - // First calculate APs and validate... - sAPCost = AP_TALK; - //sAPCost += UIPlotPath( pSoldier, sGoodGridNo, NO_COPYROUTE, FALSE, TEMPORARY, (UINT16)pSoldier->usUIMovementMode, NOT_STEALTH, FORWARD, pSoldier->bActionPoints ); + // Check distance + uiRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, usMapPos ); - // Check AP cost... - if ( !EnoughPoints( pSoldier, sAPCost, 0, TRUE ) ) - { - return( FALSE ); - } - - // Now walkup to talk.... - pSoldier->ubPendingAction = MERC_TALK; - pSoldier->uiPendingActionData1 = pTSoldier->ubID; - pSoldier->ubPendingActionAnimCount = 0; - - // WALK UP TO DEST FIRST - EVENT_InternalGetNewSoldierPath( pSoldier, sGoodGridNo, pSoldier->usUIMovementMode , TRUE , pSoldier->fNoAPToFinishMove ); - - return( FALSE ); - } - else - { - sAPCost = AP_TALK; - - // Check AP cost... - if ( !EnoughPoints( pSoldier, sAPCost, 0, TRUE ) ) - { - return( FALSE ); - } - - // OK, startup! - PlayerSoldierStartTalking( pSoldier, pTSoldier->ubID, FALSE ); - } - - if ( GetCivType( pTSoldier ) != CIV_TYPE_NA ) + // Double check path + if ( GetCivType( pTSoldier ) != CIV_TYPE_NA ) + { + // ATE: If one is already active, just remove it! + if ( ShutDownQuoteBoxIfActive( ) ) { return( FALSE ); } - else - { - return( TRUE ); - } } + + //lal + if ( pTSoldier->bTeam == MILITIA_TEAM ) + { + commandRange = NPC_TALK_RADIUS*3; + } + else + { + commandRange = NPC_TALK_RADIUS; + } + + + if ( ( uiRange > commandRange ) && ( !CheckIfRadioIsEquipped() ) ) //lal + { + // First get an adjacent gridno.... + sActionGridNo = FindAdjacentGridEx( pSoldier, pTSoldier->sGridNo, &ubDirection, NULL, FALSE, TRUE ); + + if ( sActionGridNo == -1 ) + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ NO_PATH ] ); + return( FALSE ); + } + + if ( UIPlotPath( pSoldier, sActionGridNo, NO_COPYROUTE, FALSE, TEMPORARY, (UINT16)pSoldier->usUIMovementMode, NOT_STEALTH, FORWARD, pSoldier->bActionPoints ) == 0 ) + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ NO_PATH ] ); + return( FALSE ); + } + + // Walk up and talk to buddy.... + gfNPCCircularDistLimit = TRUE; + sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, pSoldier->usUIMovementMode, pTSoldier->sGridNo, (NPC_TALK_RADIUS-1), &ubNewDirection, TRUE ); + gfNPCCircularDistLimit = FALSE; + + // First calculate APs and validate... + sAPCost = AP_TALK; + //sAPCost += UIPlotPath( pSoldier, sGoodGridNo, NO_COPYROUTE, FALSE, TEMPORARY, (UINT16)pSoldier->usUIMovementMode, NOT_STEALTH, FORWARD, pSoldier->bActionPoints ); + + // Check AP cost... + if ( !EnoughPoints( pSoldier, sAPCost, 0, TRUE ) ) + { + return( FALSE ); + } + + // Now walkup to talk.... + pSoldier->ubPendingAction = MERC_TALK; + pSoldier->uiPendingActionData1 = pTSoldier->ubID; + pSoldier->ubPendingActionAnimCount = 0; + + // WALK UP TO DEST FIRST + EVENT_InternalGetNewSoldierPath( pSoldier, sGoodGridNo, pSoldier->usUIMovementMode , TRUE , pSoldier->fNoAPToFinishMove ); + + return( FALSE ); + } + else + { + sAPCost = AP_TALK; + + // Check AP cost... + if ( !EnoughPoints( pSoldier, sAPCost, 0, TRUE ) ) + { + return( FALSE ); + } + + // OK, startup! + PlayerSoldierStartTalking( pSoldier, pTSoldier->ubID, FALSE ); + } + + if ( GetCivType( pTSoldier ) != CIV_TYPE_NA ) + { + return( FALSE ); + } + else + { + return( TRUE ); + } + } } return( FALSE ); diff --git a/Tactical/Handle UI.h b/Tactical/Handle UI.h index 8687bb5cf..a4c474ffb 100644 --- a/Tactical/Handle UI.h +++ b/Tactical/Handle UI.h @@ -340,6 +340,7 @@ void GotoHeigherStance( SOLDIERTYPE *pSoldier ); BOOLEAN IsValidJumpLocation( SOLDIERTYPE *pSoldier, INT16 sGridNo , BOOLEAN fCheckForPath); void PopupAssignmentMenuInTactical( SOLDIERTYPE *pSoldier ); +void PopupMilitiaControlMenu( SOLDIERTYPE *pSoldier ); //lal void PreventFromTheFreezingBug(SOLDIERTYPE* pSoldier); diff --git a/Tactical/Interface Control.cpp b/Tactical/Interface Control.cpp index 4afc74e45..cf48f5cd9 100644 --- a/Tactical/Interface Control.cpp +++ b/Tactical/Interface Control.cpp @@ -78,6 +78,7 @@ BOOLEAN gfPausedTacticalRenderFlags = FALSE; // which assignment menu can be shown? extern void DetermineWhichAssignmentMenusCanBeShown( void ); +extern void DetermineWhichMilitiaControlMenusCanBeShown( void ); //lal extern void HandleAnyMercInSquadHasCompatibleStuff( UINT8 ubSquad, OBJECTTYPE *pObject, BOOLEAN fReset ); extern BOOLEAN RemoveFlashItemSlot( ITEM_POOL *pItemPool ); @@ -346,6 +347,10 @@ void ResetInterface( ) DetermineWhichAssignmentMenusCanBeShown(); CreateDestroyAssignmentPopUpBoxes( ); + DetermineWhichMilitiaControlMenusCanBeShown( ); //lal + CreateDestroyMilitiaControlPopUpBoxes( ); + + HideUICursor( ); ResetPhysicsTrajectoryUI( ); diff --git a/Tactical/Militia Control.cpp b/Tactical/Militia Control.cpp index 2d480e7c5..cf3b55efa 100644 --- a/Tactical/Militia Control.cpp +++ b/Tactical/Militia Control.cpp @@ -12,8 +12,90 @@ #include "PreBattle Interface.h" #endif + BOOLEAN gfStrategicMilitiaChangesMade = FALSE; +BOOLEAN fFirstClickInMilitiaControlScreenMask = FALSE; + + +// render pre battle interface? +extern BOOLEAN gfRenderPBInterface; +extern BOOLEAN fMapScreenBottomDirty; + + +// PopUp Box Handles +INT32 ghMilitiaControlBox = -1; +//INT32 ghTalkToAllBox = -1; + + +// the x,y position of assignment pop up in tactical +INT16 gsMilitiaControlBoxesX, gsMilitiaControlBoxesY; +//INT16 gsTalkToAllBoxesX, gsTalkToAllBoxesY; + + +// assignment menu mouse regions +MOUSE_REGION gMilitiaControlMenuRegion[ MAX_MILCON_STRING_COUNT ]; +//MOUSE_REGION gTalkToAllMenuRegion[ MAX_TRAIN_STRING_COUNT ]; + +MOUSE_REGION gMilitiaControlScreenMaskRegion; + + +// pop up menu mouse regions +void CreateDestroyMouseRegionsForMilitiaControlMenu( void ); +void MilitiaControlMenuMvtCallBack(MOUSE_REGION * pRegion, INT32 iReason ); +void MilitiaControlMenuBtnCallBack( MOUSE_REGION * pRegion, INT32 iReason ); + +//void CreateDestroyMouseRegionsForTalkToAllMenu( void ); +//void TalkToAllMenuMvtCallBack(MOUSE_REGION * pRegion, INT32 iReason ); +//void TalkToAllMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason ); + + +// assignment screen mask +void MilitiaControlScreenMaskBtnCallback(MOUSE_REGION * pRegion, INT32 iReason ); +void CreateDestroyScreenMaskForMilitiaControlMenus( void ); + + +// misc assignment GUI functions +void HandleShadingOfLinesForMilitiaControlMenu( void ); +//void HandleShadingOfLinesForTalkToAllMenu( void ); + +void PositionCursorForMilitiaControlBox( void ); + +void RepositionMouseRegionsForMilitiaControl( void ); + +void CheckAndUpdateTacticalMilitiaControlPopUpPositions( void ); + + +// create assignments box +void CreateMilitiaControlBox( void ); +//void CreateTalkToAllBox( void ); + + +// rebuild assignments box +void RebuildMilitiaControlBox( void ); + + +//funktions for soldier control +extern INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem ); +extern SOLDIERTYPE *GetSelectedAssignSoldier( BOOLEAN fNullOK ); +extern SOLDIERTYPE *pTMilitiaSoldier; +extern BOOLEAN SoldierCanAffordNewStance( SOLDIERTYPE *pSoldier, UINT8 ubDesiredStance ); + + + + + + + + + + + + + + + + void ResetMilitia() { if( gfStrategicMilitiaChangesMade || gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) @@ -127,4 +209,1890 @@ void HandleMilitiaPromotions( void ) // BuildMilitiaPromotionsString( str ); // DoScreenIndependantMessageBox( str, MSG_BOX_FLAG_OK, NULL ); } -} \ No newline at end of file +} + + + + + + + + + + + + + + + +//lal + + +void RebuildMilitiaControlBox( void ) +{ + // destroy and recreate MilitiaControls box + if ( ghMilitiaControlBox != -1 ) + { + RemoveBox( ghMilitiaControlBox ); + ghMilitiaControlBox = -1; + } + + CreateMilitiaControlBox( ); +} + + +void MilitiaControlMenuMvtCallBack(MOUSE_REGION * pRegion, INT32 iReason ) +{ + // mvt callback handler for MilitiaControl region + INT32 iValue = -1; + + iValue = MSYS_GetRegionUserData( pRegion, 0 ); + + if (iReason & MSYS_CALLBACK_REASON_GAIN_MOUSE ) + { + // highlight string + if( GetBoxShadeFlag( ghMilitiaControlBox, iValue ) == FALSE ) + { + // get the string line handle + HighLightBoxLine( ghMilitiaControlBox, iValue ); + } + } + else if (iReason & MSYS_CALLBACK_REASON_LOST_MOUSE ) + { + // unhighlight all strings in box + UnHighLightBox( ghMilitiaControlBox ); + } +} + + + + + +void DetermineWhichMilitiaControlMenusCanBeShown( void ) +{ + BOOLEAN fCharacterNoLongerValid = FALSE; + SOLDIERTYPE *pSoldier = NULL; + + if ( (guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) ) + { + if( fShowMapScreenMovementList == TRUE ) + { + if( bSelectedDestChar == -1 ) + { + fCharacterNoLongerValid = TRUE; + //HandleShowingOfMovementBox( ); //laltodo + } + else + { + fShowMapScreenMovementList = FALSE; + fCharacterNoLongerValid = TRUE; + } + } + else if( bSelectedAssignChar == -1 ) + { + fCharacterNoLongerValid = TRUE; + } + + // update the assignment positions + UpdateMapScreenMilitiaControlPositions( ); + } + //ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"start DetermineWhichMilitiaControlMenusCanBeShown" ); + + // determine which assign menu needs to be shown + if( ( ( fShowMilitiaControlMenu == FALSE ) )||( fCharacterNoLongerValid == TRUE ) ) + { + // reset show MilitiaControl menu + fShowMilitiaControlMenu = FALSE; + //fShowTalkToAllMenu = FALSE; + + //ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"ShowMilitiaControlMenu = FALSE" ); + + // destroy mask, if needed + CreateDestroyScreenMaskForMilitiaControlMenus( ); + + // destroy menu if needed + CreateDestroyMouseRegionsForMilitiaControlMenu( ); + //CreateDestroyMouseRegionsForTalkToAllMenu( ); + + if ( IsBoxShown( ghMilitiaControlBox ) ) + { + HideBox( ghMilitiaControlBox ); + fTeamPanelDirty = TRUE; + gfRenderPBInterface = TRUE; + } + + //if ( IsBoxShown( ghTalkToAllBox ) ) + //{ + // HideBox( ghTalkToAllBox ); + // fTeamPanelDirty = TRUE; + // gfRenderPBInterface = TRUE; + //} + + // no menus, leave + return; + } + + // update the assignment positions + UpdateMapScreenMilitiaControlPositions( ); + + // create mask, if needed + CreateDestroyScreenMaskForMilitiaControlMenus( ); + + // created assignment menu if needed + CreateDestroyMouseRegionsForMilitiaControlMenu( ); + //CreateDestroyMouseRegionsForTalkToAllMenu( ); + + // Militia Command menu + if( fShowMilitiaControlMenu == TRUE ) + { + HandleShadingOfLinesForMilitiaControlMenu( ); + ShowBox( ghMilitiaControlBox ); + } + else + { + if( IsBoxShown( ghMilitiaControlBox ) ) + { + HideBox( ghMilitiaControlBox ); + fTeamPanelDirty = TRUE; + fMapPanelDirty = TRUE; + gfRenderPBInterface = TRUE; + } + } + + // Talk to all menu + //if( fShowTalkToAllMenu == TRUE ) + //{ + // HandleShadingOfLinesForTalkToAllMenu( ); + // ShowBox( ghTalkToAllBox ); + //} + //else + //{ + // if( IsBoxShown( ghTalkToAllBox ) ) + // { + // HideBox( ghTalkToAllBox ); + // fTeamPanelDirty = TRUE; + // fMapPanelDirty = TRUE; + // gfRenderPBInterface = TRUE; + // } + //} + + return; +} + +void CreateDestroyScreenMaskForMilitiaControlMenus( void ) +{ + static BOOLEAN fCreated = FALSE; + // will create a screen mask to catch mouse input to disable MilitiaControl menus + + // not created, create + if( ( fCreated == FALSE ) && ( fShowMilitiaControlMenu == TRUE ) ) + { + MSYS_DefineRegion( &gMilitiaControlScreenMaskRegion, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, MSYS_PRIORITY_HIGHEST - 4 , + MSYS_NO_CURSOR, MSYS_NO_CALLBACK, MilitiaControlScreenMaskBtnCallback ); + + // created + fCreated = TRUE; + + if ( !(guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) ) + { + MSYS_ChangeRegionCursor( &gMilitiaControlScreenMaskRegion, 0 ); + } + } + else if( ( fCreated == TRUE ) && ( fShowMilitiaControlMenu == FALSE ) ) + { + // created, get rid of it + MSYS_RemoveRegion( &gMilitiaControlScreenMaskRegion ); + + // not created + fCreated = FALSE; + } + + return; +} + + +void MilitiaControlScreenMaskBtnCallback(MOUSE_REGION * pRegion, INT32 iReason ) +{ + // btn callback handler for MilitiaControl screen mask region + + if( ( iReason & MSYS_CALLBACK_REASON_LBUTTON_UP ) || ( iReason & MSYS_CALLBACK_REASON_RBUTTON_UP ) ) + { + if( fFirstClickInMilitiaControlScreenMask == TRUE ) + { + fFirstClickInMilitiaControlScreenMask = FALSE; + return; + } + + // button event, stop showing menus + fShowMilitiaControlMenu = FALSE; + + // update mapscreen + fTeamPanelDirty = TRUE; + fCharacterInfoPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + + gfRenderPBInterface = TRUE; + SetRenderFlags( RENDER_FLAG_FULL ); + } + return; +} + + + +void CreateDestroyMouseRegionsForMilitiaControlMenu( void ) +{ + static BOOLEAN fCreated = FALSE; + UINT32 iCounter = 0; + INT32 iFontHeight = 0; + INT32 iBoxXPosition = 0; + INT32 iBoxYPosition = 0; + SOLDIERTYPE *pSoldier = NULL; + SGPPoint pPosition; + INT32 iBoxWidth = 0; + SGPRect pDimensions; + static BOOLEAN fShowRemoveMenu = FALSE; + + + // will create/destroy mouse regions for the map screen assignment main menu + // check if we can only remove character from team..not assign + //if( ( bSelectedAssignChar != -1 ) || ( fShowRemoveMenu == TRUE ) ) + //{ + // if( fShowRemoveMenu == TRUE ) + // { + // // dead guy handle menu stuff + // fShowRemoveMenu = fShowMilitiaControlMenu | fShowContractMenu; + // + // CreateDestroyMouseRegionsForRemoveMenu( ); + + // return; + // } + // if( ( Menptr[gCharactersList[bSelectedAssignChar].usSolID].bLife == 0 ) || ( Menptr[gCharactersList[bSelectedAssignChar].usSolID].bMilitiaControl == MilitiaControl_POW ) ) + // { + // // dead guy handle menu stuff + // fShowRemoveMenu = fShowMilitiaControlMenu | fShowContractMenu; + // + // CreateDestroyMouseRegionsForRemoveMenu( ); + + // return; + // } + //} + + + if( ( fShowMilitiaControlMenu == TRUE ) && ( fCreated == FALSE ) ) + { + gfIgnoreScrolling = FALSE; + + if( ( fShowMilitiaControlMenu ) && ( guiCurrentScreen == MAP_SCREEN ) ) + { + SetBoxPosition( ghMilitiaControlBox, MilitiaControlPosition ); + } + + //pSoldier = GetSelectedAssignSoldier( FALSE ); + + //if( pSoldier -> ubWhatKindOfMercAmI != MERC_TYPE__EPC ) //laltodo + { + // grab height of font + iFontHeight = GetLineSpace( ghMilitiaControlBox ) + GetFontHeight( GetBoxFont( ghMilitiaControlBox ) ); + + // get x.y position of box + GetBoxPosition( ghMilitiaControlBox, &pPosition); + + // grab box x and y position + iBoxXPosition = pPosition.iX; + iBoxYPosition = pPosition.iY; + + // get dimensions..mostly for width + GetBoxSize( ghMilitiaControlBox, &pDimensions ); + + // get width + iBoxWidth = pDimensions.iRight; + + SetCurrentBox( ghMilitiaControlBox ); + } + + + // define regions + for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghMilitiaControlBox ); iCounter++ ) + { + // add mouse region for each line of text..and set user data + MSYS_DefineRegion( &gMilitiaControlMenuRegion[ iCounter ], ( INT16 )( iBoxXPosition ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghMilitiaControlBox ) + ( iFontHeight ) * iCounter ), ( INT16 )( iBoxXPosition + iBoxWidth ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghMilitiaControlBox ) + ( iFontHeight ) * ( iCounter + 1 ) ), MSYS_PRIORITY_HIGHEST - 4 , + MSYS_NO_CURSOR, MilitiaControlMenuMvtCallBack, MilitiaControlMenuBtnCallBack ); + + MSYS_SetRegionUserData( &gMilitiaControlMenuRegion[ iCounter ], 0, iCounter ); + } + + // created + fCreated = TRUE; + + // unhighlight all strings in box + UnHighLightBox( ghMilitiaControlBox ); + CheckAndUpdateTacticalMilitiaControlPopUpPositions( ); + + //PositionCursorForMilitiaControlBox( ); + } + else if( ( fShowMilitiaControlMenu == FALSE ) && ( fCreated == TRUE ) ) + { + // destroy + for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghMilitiaControlBox ); iCounter++ ) + { + MSYS_RemoveRegion( &gMilitiaControlMenuRegion[ iCounter ] ); + } + + // not created + fCreated = FALSE; + SetRenderFlags( RENDER_FLAG_FULL ); + } +} + + + +void CreateMilitiaControlBox( void ) +{ + UINT32 hStringHandle; + UINT32 uiCounter; + CHAR16 sString[ 128 ]; + //SOLDIERTYPE *pSoldier = NULL; + + + // will create attribute pop up menu for mapscreen MilitiaControls + + MilitiaControlPosition.iX = OrigMilitiaControlPosition.iX; + + if( giBoxY != 0 ) + { + MilitiaControlPosition.iY = giBoxY; + } + + //pSoldier = GetSelectedAssignSoldier( TRUE ); + // pSoldier NULL is legal here! Gets called during every mapscreen initialization even when nobody is assign char + + // create basic box + CreatePopUpBox(&ghMilitiaControlBox, MilitiaControlDimensions, MilitiaControlPosition, (POPUP_BOX_FLAG_CLIP_TEXT|POPUP_BOX_FLAG_CENTER_TEXT|POPUP_BOX_FLAG_RESIZE )); + + // which buffer will box render to + SetBoxBuffer(ghMilitiaControlBox, FRAME_BUFFER); + + // border type? + SetBorderType(ghMilitiaControlBox,guiPOPUPBORDERS); + + // background texture + SetBackGroundSurface(ghMilitiaControlBox, guiPOPUPTEX); + + // margin sizes + SetMargins(ghMilitiaControlBox, 6, 6, 4, 4 ); + + // space between lines + SetLineSpace(ghMilitiaControlBox, 2); + + // set current box to this one + SetCurrentBox( ghMilitiaControlBox ); + + // add strings for box + for(uiCounter=0; uiCounter < MAX_MILCON_STRING_COUNT; uiCounter++) + { + swprintf( sString, pMilitiaControlMenuStrings[uiCounter] ); + + AddMonoString(&hStringHandle, sString ); + + // make sure it is unhighlighted + UnHighLightLine(hStringHandle); + } + + // set font type + SetBoxFont(ghMilitiaControlBox, MAP_SCREEN_FONT); + + // set highlight color + SetBoxHighLight(ghMilitiaControlBox, FONT_WHITE); + + // unhighlighted color + SetBoxForeground(ghMilitiaControlBox, FONT_LTGREEN); + + // background color + SetBoxBackground(ghMilitiaControlBox, FONT_BLACK); + + // shaded color..for darkened text + SetBoxShade( ghMilitiaControlBox, FONT_GRAY7 ); + SetBoxSecondaryShade( ghMilitiaControlBox, FONT_YELLOW ); + + // resize box to text + ResizeBoxToText( ghMilitiaControlBox ); + + //DetermineMilitiaControlBoxPositions( ); //laltodo +} + + +BOOLEAN CreateDestroyMilitiaControlPopUpBoxes( void ) +{ + static BOOLEAN fCreated= FALSE; + VSURFACE_DESC vs_desc; + VOBJECT_DESC VObjectDesc; + + + if( ( fShowMilitiaControlMenu == TRUE ) && ( fCreated == FALSE ) ) + { + VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE; + FilenameForBPP("INTERFACE\\popup.sti", VObjectDesc.ImageFile); + CHECKF(AddVideoObject(&VObjectDesc, &guiPOPUPBORDERS)); + + vs_desc.fCreateFlags = VSURFACE_CREATE_FROMFILE | VSURFACE_SYSTEM_MEM_USAGE; + strcpy(vs_desc.ImageFile, "INTERFACE\\popupbackground.pcx"); + CHECKF(AddVideoSurface(&vs_desc, &guiPOPUPTEX)); + + // these boxes are always created while in mapscreen... + CreateMilitiaControlBox( ); + //CreateTalkToAllBox( ); + + UpdateMapScreenMilitiaControlPositions( ); + + fCreated = TRUE; + } + else if( ( fShowMilitiaControlMenu == FALSE ) && ( fCreated == TRUE ) ) + { + DeleteVideoObjectFromIndex(guiPOPUPBORDERS); + DeleteVideoSurfaceFromIndex(guiPOPUPTEX); + + RemoveBox(ghMilitiaControlBox); + ghMilitiaControlBox = -1; + + //RemoveBox(ghTalkToAllBox); + //ghTalkToAllBox = -1; + + fCreated = FALSE; + gfIgnoreScrolling = FALSE; + } + + return( TRUE ); +} + + +void DetermineMilitiaControlBoxPositions( void ) +{ + // depending on how many boxes there are, reposition as needed + SGPPoint pPoint; + SGPPoint pNewPoint; + SGPRect pDimensions; + SOLDIERTYPE *pSoldier = NULL; + + + if( ( fShowMilitiaControlMenu == FALSE ) || ( ghMilitiaControlBox == -1 ) ) + { + return; + } + + pSoldier = GetSelectedAssignSoldier( TRUE ); + // pSoldier NULL is legal here! Gets called during every mapscreen initialization even when nobody is assign char + if ( pSoldier == NULL ) + { + return; + } + + if ( (guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) ) + { + GetBoxPosition( ghMilitiaControlBox, &pPoint ); + gsMilitiaControlBoxesX = ( INT16 )pPoint.iX; + gsMilitiaControlBoxesY = ( INT16 )pPoint.iY; + } + + pPoint.iX = gsMilitiaControlBoxesX; + pPoint.iY = gsMilitiaControlBoxesY; + + + SetBoxPosition( ghMilitiaControlBox, pPoint ); + GetBoxSize( ghMilitiaControlBox, &pDimensions ); + + + // hang it right beside the MilitiaControl/EPC box menu + pNewPoint.iX = pPoint.iX + pDimensions.iRight; + pNewPoint.iY = pPoint.iY; + + + + //if( ( fShowTalkToAllMenu == TRUE ) && ( ghTalkToAllBox != -1 ) ) + //{ + // pNewPoint.iY += ( ( GetFontHeight( MAP_SCREEN_FONT ) + 2 ) * MILCON_MENU_ALL ); + // SetBoxPosition( ghTalkToAllBox, pNewPoint ); + // TrainPosition.iX = pNewPoint.iX; + // TrainPosition.iY = pNewPoint.iY; + // OrigTrainPosition.iY = pNewPoint.iY; + // OrigTrainPosition.iX = pNewPoint.iX; + + // GetBoxSize( ghTalkToAllBox, &pDimensions ); + // GetBoxPosition( ghTalkToAllBox, &pPoint ); + //} + + return; +} + + + +void SetTacticalPopUpMilitiaControlBoxXY( SOLDIERTYPE *pSoldier ) +{ + INT16 sX, sY; + //SOLDIERTYPE *pSoldier; + + //get the soldier + //pSoldier = GetSelectedAssignSoldier( FALSE ); //gives wrong position (0,0) when cursor moved + + //if ( !GetSoldier( &pSoldier, gusSelectedSoldier ) ) + //{ + // //ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"No Soldier" ); + // return; + //} + + // grab soldier's x,y screen position + GetSoldierScreenPos( pSoldier, &sX, &sY ); + + //ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"X-Position: %d", sX ); + //ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"Y-Position: %d", sY ); + + if( sX < 0 ) + { + sX = 0; + } + + gsMilitiaControlBoxesX = sX + 30; + + if( sY < 0 ) + { + sY = 0; + } + + gsMilitiaControlBoxesY = sY; + + // ATE: Check if we are past tactical viewport.... + // Use estimate width's/heights + if ( ( gsMilitiaControlBoxesX + 100 ) > SCREEN_WIDTH ) + { + gsMilitiaControlBoxesX = SCREEN_WIDTH - 100; + } + + if ( ( gsMilitiaControlBoxesY + 130 ) > SCREEN_HEIGHT ) + { + gsMilitiaControlBoxesY = SCREEN_HEIGHT - 190; + } + + return; +} + + +void CheckAndUpdateTacticalMilitiaControlPopUpPositions( void ) +{ + SGPRect pDimensions2; + SGPPoint pPoint; + //SOLDIERTYPE *pSoldier = NULL; + + + if( fShowMilitiaControlMenu == FALSE ) + { + return; + } + + if ( (guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) ) + { + return; + } + + //get the soldier + //pSoldier = GetSelectedAssignSoldier( FALSE ); + + //if( pSoldier -> ubWhatKindOfMercAmI == MERC_TYPE__EPC ) //laltodo + { + GetBoxSize( ghMilitiaControlBox, &pDimensions2 ); + } + + // just the MilitiaControl box + if( gsMilitiaControlBoxesX + pDimensions2.iRight >= SCREEN_WIDTH ) + { + gsMilitiaControlBoxesX = ( INT16 ) ( SCREEN_WIDTH - 1 - ( pDimensions2.iRight ) ); + SetRenderFlags( RENDER_FLAG_FULL ); + } + + if( gsMilitiaControlBoxesY + pDimensions2.iBottom >= SCREEN_HEIGHT-120 ) + { + gsMilitiaControlBoxesY = ( INT16 )( SCREEN_HEIGHT - 121 - ( pDimensions2.iBottom ) ); + SetRenderFlags( RENDER_FLAG_FULL ); + } + + pPoint.iX = gsMilitiaControlBoxesX; + pPoint.iY = gsMilitiaControlBoxesY; + + //if( pSoldier -> ubWhatKindOfMercAmI != MERC_TYPE__EPC) //laltodo + { + SetBoxPosition( ghMilitiaControlBox, pPoint ); + } + + RepositionMouseRegionsForMilitiaControl( ); +} + + +void RepositionMouseRegionsForMilitiaControl( void ) +{ + INT16 sDeltaX, sDeltaY; + INT32 iCounter = 0; + + if( fShowMilitiaControlMenu == TRUE ) + { + sDeltaX = gsMilitiaControlBoxesX - gMilitiaControlMenuRegion[ 0 ].RegionTopLeftX; + sDeltaY = ( INT16 ) ( gsMilitiaControlBoxesY - gMilitiaControlMenuRegion[ 0 ].RegionTopLeftY + GetTopMarginSize( ghMilitiaControlBox ) ); + + // find the delta from the old to the new, and alter values accordingly + for( iCounter = 0; iCounter < ( INT32 )GetNumberOfLinesOfTextInBox( ghMilitiaControlBox ); iCounter++ ) + { + gMilitiaControlMenuRegion[ iCounter ].RegionTopLeftX += sDeltaX; + gMilitiaControlMenuRegion[ iCounter ].RegionTopLeftY += sDeltaY; + + gMilitiaControlMenuRegion[ iCounter ].RegionBottomRightX += sDeltaX; + gMilitiaControlMenuRegion[ iCounter ].RegionBottomRightY += sDeltaY; + } + + gfPausedTacticalRenderFlags = RENDER_FLAG_FULL; + } +} + + + +void PositionCursorForMilitiaControlBox( void ) +{ + // position cursor over y of on duty in tactical assignments + SGPPoint pPosition; + SGPRect pDimensions; + INT32 iFontHeight; + + // get x.y position of box + GetBoxPosition( ghMilitiaControlBox, &pPosition); + + // get dimensions..mostly for width + GetBoxSize( ghMilitiaControlBox, &pDimensions ); + + iFontHeight = GetLineSpace( ghMilitiaControlBox ) + GetFontHeight( GetBoxFont( ghMilitiaControlBox ) ); + + if( gGameSettings.fOptions[ TOPTION_DONT_MOVE_MOUSE ] == FALSE ) + { + SimulateMouseMovement( pPosition.iX + pDimensions.iRight - 6, pPosition.iY + ( iFontHeight / 2 ) + 2 ); + } +} + + +void HandleShadingOfLinesForMilitiaControlMenu( void ) +{ + SOLDIERTYPE *pSoldier = NULL; + INT16 sDistVisible; + + // check if valid + if( ( fShowMilitiaControlMenu == FALSE ) || ( ghMilitiaControlBox == - 1 ) ) + { + return; + } + + if ( GetSoldier( &pSoldier, gusSelectedSoldier ) ) + { + sDistVisible = DistanceVisible( pSoldier, DIRECTION_IRRELEVANT, DIRECTION_IRRELEVANT, pTMilitiaSoldier->sGridNo, pTMilitiaSoldier->bLevel, pSoldier ); + + // Check LOS! + if ( SoldierTo3DLocationLineOfSightTest( pSoldier, pTMilitiaSoldier->sGridNo, pTMilitiaSoldier->bLevel, 3, (UINT8) sDistVisible, TRUE ) ) + { + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ATTACK ); + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_HOLD ); + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_RETREAT ); + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_COMETOME ); + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_GETDOWN ); + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_TAKE_COVER ); + } + else + { + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ATTACK ); + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_HOLD ); + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_RETREAT ); + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_COMETOME ); + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_GETDOWN ); + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_TAKE_COVER ); + } + } + + if ( CheckIfRadioIsEquipped() ) + { + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_ATTACK ); + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_HOLD ); + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_RETREAT ); + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_COMETOME ); + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_GETDOWN ); + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_TAKE_COVER ); + UnShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_TAKE_ITEMS ); + } + else + { + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_ATTACK ); + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_HOLD ); + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_RETREAT ); + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_COMETOME ); + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_GETDOWN ); + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_TAKE_COVER ); + ShadeStringInBox( ghMilitiaControlBox, MILCON_MENU_ALL_TAKE_ITEMS ); + } + + return; +} + + +BOOLEAN CheckIfRadioIsEquipped( void ) +{ + SOLDIERTYPE *pSoldier = NULL; + INT8 bSlot; + + // do we have a radio ? + //pSoldier = GetSelectedAssignSoldier( FALSE ); //do not use + + if ( GetSoldier( &pSoldier, gusSelectedSoldier ) ) + { + bSlot = FindObj( pSoldier, EXTENDEDEAR ); + //bSlot = FindHearingAid(pSoldier); + //ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"Position: %d", bSlot ); + } + + if (( bSlot == HEAD1POS ) || ( bSlot == HEAD2POS)) + { + return TRUE; + } + else + { + return FALSE; + } +} + + + +//INT16 sFacingDir, sXPos, sYPos, sAPCost; + +//ConvertGridNoToXY( pTMilitiaSoldier->sGridNo, &sXPos, &sYPos ); +//sFacingDir = GetDirectionFromXY( sXPos, sYPos, pTMilitiaSoldier ); +//SendSoldierSetDesiredDirectionEvent( pTMilitiaSoldier, sFacingDir ); +//SendSoldierSetDesiredDirectionEvent( pTMilitiaSoldier, gOppositeDirection[ sFacingDir ] ); +//EVENT_StopMerc( pTMilitiaSoldier, pTMilitiaSoldier->sGridNo, pTMilitiaSoldier->bDirection ); + +//SendChangeSoldierStanceEvent( pTMilitiaSoldier, ANIM_PRONE ); +//SendChangeSoldierStanceEvent( pTMilitiaSoldier, ANIM_CROUCH ); + +//pTMilitiaSoldier->bNextAction = AI_ACTION_CHANGE_STANCE; +//pTMilitiaSoldier->usActionData = ANIM_PRONE; + + + +//// some orders are more offensive, others more defensive +//switch( pSoldier->bOrders ) +//{ +// case STATIONARY: swprintf( szOrders, L"STATIONARY" ); break; +// case ONGUARD: swprintf( szOrders, L"ON GUARD" ); break; +// case ONCALL: swprintf( szOrders, L"ON CALL" ); break; +// case SEEKENEMY: swprintf( szOrders, L"SEEK ENEMY" ); break; +// case CLOSEPATROL: swprintf( szOrders, L"CLOSE PATROL" ); break; +// case FARPATROL: swprintf( szOrders, L"FAR PATROL" ); break; +// case POINTPATROL: swprintf( szOrders, L"POINT PATROL" ); break; +// case RNDPTPATROL: swprintf( szOrders, L"RND PT PATROL" ); break; +// default: swprintf( szOrders, L"UNKNOWN" ); break; +//} +//switch( pSoldier->bAttitude ) +//{ +// case DEFENSIVE: swprintf( szAttitude, L"DEFENSIVE" ); break; +// case BRAVESOLO: swprintf( szAttitude, L"BRAVE SOLO" ); break; +// case BRAVEAID: swprintf( szAttitude, L"BRAVE AID" ); break; +// case AGGRESSIVE: swprintf( szAttitude, L"AGGRESSIVE" ); break; +// case CUNNINGSOLO: swprintf( szAttitude, L"CUNNING SOLO" ); break; +// case CUNNINGAID: swprintf( szAttitude, L"CUNNING AID" ); break; +// default: swprintf( szAttitude, L"UNKNOWN" ); break; +//} + +//MILCON_MENU_ATTACK, +//MILCON_MENU_HOLD, +//MILCON_MENU_RETREAT, +//MILCON_MENU_COMETOME, +//MILCON_MENU_GETDOWN, +//MILCON_MENU_ALL_ATTACK, +//MILCON_MENU_ALL_HOLD, +//MILCON_MENU_ALL_RETREAT, +//MILCON_MENU_ALL_COMETOME, +//MILCON_MENU_ALL_GETDOWN, +//MILCON_MENU_CANCEL, +//MAX_MILCON_STRING_COUNT, + + +//AI_ACTION_NONE = 0, // maintain current position & facing + +//// actions that involve a move to another tile +//AI_ACTION_RANDOM_PATROL, // move towards a random destination +//AI_ACTION_SEEK_FRIEND, // move towards friend in trouble +//AI_ACTION_SEEK_OPPONENT, // move towards a reported opponent +//AI_ACTION_TAKE_COVER, // run for nearest cover from threat +//AI_ACTION_GET_CLOSER, // move closer to a strategic location + +//AI_ACTION_POINT_PATROL, // move towards next patrol point +//AI_ACTION_LEAVE_WATER_GAS, // seek nearest spot of ungassed land +//AI_ACTION_SEEK_NOISE, // seek most important noise heard +//AI_ACTION_ESCORTED_MOVE, // go where told to by escortPlayer +//AI_ACTION_RUN_AWAY, // run away from nearby opponent(s) + +//AI_ACTION_KNIFE_MOVE, // preparing to stab an opponent +//AI_ACTION_APPROACH_MERC, // move up to a merc in order to talk with them; RT +//AI_ACTION_TRACK, // track a scent +//AI_ACTION_EAT, // monster eats corpse +//AI_ACTION_PICKUP_ITEM, // grab things lying on the ground + +//AI_ACTION_SCHEDULE_MOVE, // move according to schedule +//AI_ACTION_WALK, // walk somewhere (NPC stuff etc) +//AI_ACTION_RUN, // run somewhere (NPC stuff etc) +//AI_ACTION_WITHDRAW, // back off +//AI_ACTION_FLANK_LEFT, // move to the left +//AI_ACTION_FLANK_RIGHT, // move to the right +//AI_ACTION_MOVE_TO_CLIMB, // move to edge of roof/building +//// miscellaneous movement actions +//AI_ACTION_CHANGE_FACING, // turn to face a different direction + +//AI_ACTION_CHANGE_STANCE, // stand, crouch, or go prone +//// actions related to items and attacks +//AI_ACTION_YELLOW_ALERT, // tell friends opponent(s) heard +//AI_ACTION_RED_ALERT, // tell friends opponent(s) seen +//AI_ACTION_CREATURE_CALL, // creature communication +//AI_ACTION_PULL_TRIGGER, // go off to activate a panic trigger + +//AI_ACTION_USE_DETONATOR, // grab detonator and set off bomb(s) +//AI_ACTION_FIRE_GUN, // shoot at nearby opponent +//AI_ACTION_TOSS_PROJECTILE, // throw grenade at/near opponent(s) +//AI_ACTION_KNIFE_STAB, // during the actual knifing attack +//AI_ACTION_THROW_KNIFE, // throw a knife + +//AI_ACTION_GIVE_AID, // help injured/dying friend +//AI_ACTION_WAIT, // RT: don't do anything for a certain length of time +//AI_ACTION_PENDING_ACTION, // RT: wait for pending action (pickup, door open, etc) to finish +//AI_ACTION_DROP_ITEM, // duh +//AI_ACTION_COWER, // for civilians: cower in fear and stay there! + +//AI_ACTION_STOP_COWERING, // stop cowering +//AI_ACTION_OPEN_OR_CLOSE_DOOR, // schedule-provoked; open or close door +//AI_ACTION_UNLOCK_DOOR, // schedule-provoked; unlock door (don't open) +//AI_ACTION_LOCK_DOOR, // schedule-provoked; lock door (close if necessary) +//AI_ACTION_LOWER_GUN, // lower gun prior to throwing knife + +//AI_ACTION_ABSOLUTELY_NONE, // like "none" but can't be converted to a wait by realtime +//AI_ACTION_CLIMB_ROOF, // climb up or down roof +//AI_ACTION_END_TURN, // end turn (after final stance change) +//AI_ACTION_END_COWER_AND_MOVE, // sort of dummy value, special for civilians who are to go somewhere at end of battle +//AI_ACTION_TRAVERSE_DOWN, // move down a level +//AI_ACTION_OFFER_SURRENDER, // offer surrender to the player + + +//// stand up! +//pSoldier->bAction = AI_ACTION_CHANGE_STANCE; +//pSoldier->usActionData = ANIM_STAND; +// +// + +//pSoldier->bAction = pSoldier->bNextAction; +//pSoldier->usActionData = pSoldier->usNextActionData; +//pSoldier->bTargetLevel = pSoldier->bNextTargetLevel; +//pSoldier->bNextAction = AI_ACTION_NONE; +//pSoldier->usNextActionData = 0; +//pSoldier->bNextTargetLevel = 0; +// + + +//EV_S_CHANGESTATE SChangeState; +//EV_S_CHANGEDEST SChangeDest; +//EV_S_SETPOSITION SSetPosition; +//EV_S_GETNEWPATH SGetNewPath; +//EV_S_BEGINTURN SBeginTurn; +//EV_S_CHANGESTANCE SChangeStance; +//EV_S_SETDIRECTION SSetDirection; +//EV_S_SETDESIREDDIRECTION SSetDesiredDirection; +//EV_S_BEGINFIREWEAPON SBeginFireWeapon; +//EV_S_FIREWEAPON SFireWeapon; +//EV_S_WEAPONHIT SWeaponHit; +//EV_S_STRUCTUREHIT SStructureHit; +//EV_S_WINDOWHIT SWindowHit; +//EV_S_MISS SMiss; +//EV_S_NOISE SNoise; +//EV_S_STOP_MERC SStopMerc; +//EV_S_SENDPATHTONETWORK SUpdateNetworkSoldier; + +void MilitiaControlMenuBtnCallBack( MOUSE_REGION * pRegion, INT32 iReason ) +{ + // btn callback handler for MilitiaControl region + INT32 iValue = -1; + SOLDIERTYPE * pSoldier = NULL; + UINT8 ubVolume = 10; + + //pSoldier = GetSelectedAssignSoldier( FALSE ); + + iValue = MSYS_GetRegionUserData( pRegion, 0 ); + + if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP) + { + //if( ( fShowTalkToAllMenu ) ) + //{ + // return; + //} + + UnHighLightBox( ghMilitiaControlBox ); + + //if( pSoldier -> ubWhatKindOfMercAmI != MERC_TYPE__EPC ) //laltodo + { + switch( iValue ) + { + case( MILCON_MENU_ATTACK ): + { + // Attack !!! + + pTMilitiaSoldier->bOrders = SEEKENEMY; + pTMilitiaSoldier->bAttitude = AGGRESSIVE; + pTMilitiaSoldier->usUIMovementMode = RUNNING; + + if ( GetSoldier( &pSoldier, gusSelectedSoldier ) ) + { + //ubVolume = CalcScreamVolume( pSoldier, 10 ); + MakeNoise( pSoldier->ubID, pSoldier->sGridNo, pSoldier->bLevel, pSoldier->bOverTerrainType, ubVolume, NOISE_SCREAM); + } + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + case( MILCON_MENU_HOLD ): + { + //Hold Position !!! + //ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"Hold Position" ); + pTMilitiaSoldier->bOrders = STATIONARY; + //pTMilitiaSoldier->bAttitude = DEFENSIVE; + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + case( MILCON_MENU_RETREAT ): + { + INT16 sActionGridNo; + + pTMilitiaSoldier->bOrders = FARPATROL; + pTMilitiaSoldier->bAttitude = DEFENSIVE; + pTMilitiaSoldier->usUIMovementMode = RUNNING; + + // set up next action to run away + sActionGridNo = FindSpotMaxDistFromOpponents( pTMilitiaSoldier ); + + pTMilitiaSoldier->usNextActionData = sActionGridNo; + + if ( pTMilitiaSoldier->usNextActionData != NOWHERE ) + { + pTMilitiaSoldier->bNextAction = AI_ACTION_RUN_AWAY; + pTMilitiaSoldier->usActionData = ANIM_STAND; + + // SEND PENDING ACTION + pTMilitiaSoldier->sPendingActionData2 = sActionGridNo; + pTMilitiaSoldier->ubPendingActionAnimCount = 0; + } + + if ( pTMilitiaSoldier->sGridNo != sActionGridNo ) + { + SendGetNewSoldierPathEvent( pTMilitiaSoldier, sActionGridNo, pTMilitiaSoldier->usUIMovementMode ); + } + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + case( MILCON_MENU_COMETOME ): + { + INT16 sActionGridNo, sGridNo, sAdjustedGridNo; + UINT8 ubDirection; + + if ( GetSoldier( &pSoldier, gusSelectedSoldier ) ) + { + // OK, find an adjacent gridno.... + sGridNo = pSoldier->sGridNo; + + // See if we can get there + sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); + if ( sActionGridNo != -1 ) + { + // SEND PENDING ACTION + //pTMilitiaSoldier->ubPendingAction = MERC_STEAL; + pTMilitiaSoldier->sPendingActionData2 = pSoldier->sGridNo; + //pTMilitiaSoldier->bPendingActionData3 = ubDirection; + pTMilitiaSoldier->ubPendingActionAnimCount = 0; + pTMilitiaSoldier->usUIMovementMode = RUNNING; + + // CHECK IF WE ARE AT THIS GRIDNO NOW + if ( pTMilitiaSoldier->sGridNo != sActionGridNo ) + { + // WALK UP TO DEST FIRST + SendGetNewSoldierPathEvent( pTMilitiaSoldier, sActionGridNo, pTMilitiaSoldier->usUIMovementMode ); + } + } + } + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + case( MILCON_MENU_GETDOWN ): + { + //if ( SoldierCanAffordNewStance( pTeamSoldier, ANIM_PRONE ) ) + { + SendChangeSoldierStanceEvent( pTMilitiaSoldier, ANIM_PRONE ); + //SendChangeSoldierStanceEvent( pTMilitiaSoldier, ANIM_CROUCH ); + } + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + + case( MILCON_MENU_TAKE_COVER ): + { + INT16 sActionGridNo; + INT32 iDummy; + + sActionGridNo = FindBestNearbyCover(pTMilitiaSoldier,pTMilitiaSoldier->bAIMorale,&iDummy); + + if ( sActionGridNo != NOWHERE ) + { + // SEND PENDING ACTION + pTMilitiaSoldier->sPendingActionData2 = sActionGridNo; + pTMilitiaSoldier->ubPendingActionAnimCount = 0; + pTMilitiaSoldier->usUIMovementMode = RUNNING; + + // CHECK IF WE ARE AT THIS GRIDNO NOW + if ( pTMilitiaSoldier->sGridNo != sActionGridNo ) + { + SendGetNewSoldierPathEvent( pTMilitiaSoldier, sActionGridNo, pTMilitiaSoldier->usUIMovementMode ); + } + } + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + + case( MILCON_MENU_ALL_ATTACK ): + { + UINT8 cnt; + SOLDIERTYPE *pTeamSoldier; + + cnt = gTacticalStatus.Team[ MILITIA_TEAM ].bFirstID; + + for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ MILITIA_TEAM ].bLastID; cnt++, pTeamSoldier++) + { + if ( pTeamSoldier->bActive && pTeamSoldier->bInSector && pTeamSoldier->bLife > 0 ) + { + pTeamSoldier->bOrders = SEEKENEMY; + pTeamSoldier->bAttitude = AGGRESSIVE; + pTeamSoldier->usUIMovementMode = RUNNING; + } + } + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + case( MILCON_MENU_ALL_HOLD ): + { + UINT8 cnt; + SOLDIERTYPE *pTeamSoldier; + + cnt = gTacticalStatus.Team[ MILITIA_TEAM ].bFirstID; + + for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ MILITIA_TEAM ].bLastID; cnt++, pTeamSoldier++) + { + if ( pTeamSoldier->bActive && pTeamSoldier->bInSector && pTeamSoldier->bLife > 0 ) + { + pTeamSoldier->bOrders = STATIONARY; + pTeamSoldier->bAttitude = DEFENSIVE; + } + } + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + case( MILCON_MENU_ALL_RETREAT ): + { + UINT8 cnt; + INT16 sActionGridNo; + SOLDIERTYPE *pTeamSoldier; + + cnt = gTacticalStatus.Team[ MILITIA_TEAM ].bFirstID; + + for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ MILITIA_TEAM ].bLastID; cnt++, pTeamSoldier++) + { + if ( pTeamSoldier->bActive && pTeamSoldier->bInSector && pTeamSoldier->bLife > 0 ) + { + pTeamSoldier->bOrders = FARPATROL; + pTeamSoldier->bAttitude = DEFENSIVE; + pTeamSoldier->usUIMovementMode = RUNNING; + + //// set up next action to run away + //pTeamSoldier->usNextActionData = FindSpotMaxDistFromOpponents( pTeamSoldier ); + + //if ( pTeamSoldier->usNextActionData != NOWHERE ) + //{ + // pTeamSoldier->bNextAction = AI_ACTION_RUN_AWAY; + // pTeamSoldier->usActionData = ANIM_STAND; + //} + + // set up next action to run away + sActionGridNo = FindSpotMaxDistFromOpponents( pTeamSoldier ); + + pTeamSoldier->usNextActionData = sActionGridNo; + + if ( pTeamSoldier->usNextActionData != NOWHERE ) + { + pTeamSoldier->bNextAction = AI_ACTION_RUN_AWAY; + pTeamSoldier->usActionData = ANIM_STAND; + + // SEND PENDING ACTION + pTeamSoldier->sPendingActionData2 = sActionGridNo; + pTeamSoldier->ubPendingActionAnimCount = 0; + } + + if ( pTeamSoldier->sGridNo != sActionGridNo ) + { + SendGetNewSoldierPathEvent( pTeamSoldier, sActionGridNo, pTeamSoldier->usUIMovementMode ); + } + } + } + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + case( MILCON_MENU_ALL_COMETOME ): + { + UINT8 cnt, ubDirection; + INT16 sActionGridNo, sGridNo, sAdjustedGridNo; + SOLDIERTYPE *pTeamSoldier; + + cnt = gTacticalStatus.Team[ MILITIA_TEAM ].bFirstID; + + for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ MILITIA_TEAM ].bLastID; cnt++, pTeamSoldier++) + { + if ( pTeamSoldier->bActive && pTeamSoldier->bInSector && pTeamSoldier->bLife > 0 ) + { + if ( GetSoldier( &pSoldier, gusSelectedSoldier ) ) + { + // OK, find an adjacent gridno.... + sGridNo = pSoldier->sGridNo; + + // See if we can get there + sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); + if ( sActionGridNo != -1 ) + { + // SEND PENDING ACTION + pTeamSoldier->sPendingActionData2 = pSoldier->sGridNo; + //pTeamSoldier->bPendingActionData3 = ubDirection; + pTeamSoldier->ubPendingActionAnimCount = 0; + pTeamSoldier->usUIMovementMode = RUNNING; + + // CHECK IF WE ARE AT THIS GRIDNO NOW + if ( pTeamSoldier->sGridNo != sActionGridNo ) + { + // WALK UP TO DEST FIRST + SendGetNewSoldierPathEvent( pTeamSoldier, sActionGridNo, pTeamSoldier->usUIMovementMode ); + } + } + } + } + } + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + case( MILCON_MENU_ALL_GETDOWN ): + { + UINT8 cnt; + SOLDIERTYPE *pTeamSoldier; + + cnt = gTacticalStatus.Team[ MILITIA_TEAM ].bFirstID; + + for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ MILITIA_TEAM ].bLastID; cnt++, pTeamSoldier++) + { + if ( pTeamSoldier->bActive && pTeamSoldier->bInSector && pTeamSoldier->bLife > 0 ) + { + //if ( SoldierCanAffordNewStance( pTeamSoldier, ANIM_PRONE ) ) + { + SendChangeSoldierStanceEvent( pTeamSoldier, ANIM_PRONE ); + //SendChangeSoldierStanceEvent( pTeamSoldier, ANIM_CROUCH ); + } + } + } + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + + + case( MILCON_MENU_ALL_TAKE_COVER ): + { + //UINT8 cnt; + //SOLDIERTYPE *pTeamSoldier; + //INT32 iDummy; + + //cnt = gTacticalStatus.Team[ MILITIA_TEAM ].bFirstID; + + //for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ MILITIA_TEAM ].bLastID; cnt++, pTeamSoldier++) + //{ + // if ( pTeamSoldier->bActive && pTeamSoldier->bInSector && pTeamSoldier->bLife > 0 ) + // { + // pTeamSoldier->usActionData = FindBestNearbyCover(pTeamSoldier,pTeamSoldier->bAIMorale,&iDummy); + // + // pTeamSoldier->usNextActionData = FindBestNearbyCover(pTeamSoldier,pTeamSoldier->bAIMorale,&iDummy); + // + // //if ( pTeamSoldier->usNextActionData != NOWHERE ) + // { + // pTeamSoldier->bNextAction = AI_ACTION_TAKE_COVER; + // pTeamSoldier->usActionData = ANIM_STAND; + // } + // } + //} + + + UINT8 cnt; + INT16 sActionGridNo; + INT32 iDummy; + SOLDIERTYPE *pTeamSoldier; + + cnt = gTacticalStatus.Team[ MILITIA_TEAM ].bFirstID; + + for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ MILITIA_TEAM ].bLastID; cnt++, pTeamSoldier++) + { + if ( pTeamSoldier->bActive && pTeamSoldier->bInSector && pTeamSoldier->bLife > 0 ) + { + // See if we can get there + sActionGridNo = FindBestNearbyCover(pTeamSoldier,pTeamSoldier->bAIMorale,&iDummy); + + if ( sActionGridNo != NOWHERE ) + { + // SEND PENDING ACTION + pTeamSoldier->sPendingActionData2 = sActionGridNo; + //pTeamSoldier->bPendingActionData3 = ubDirection; + pTeamSoldier->ubPendingActionAnimCount = 0; + pTeamSoldier->usUIMovementMode = RUNNING; + + // CHECK IF WE ARE AT THIS GRIDNO NOW + if ( pTeamSoldier->sGridNo != sActionGridNo ) + { + // WALK UP TO DEST FIRST + SendGetNewSoldierPathEvent( pTeamSoldier, sActionGridNo, pTeamSoldier->usUIMovementMode ); + } + } + } + } + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + + + case( MILCON_MENU_ALL_TAKE_ITEMS ): + { + UINT8 cnt; + SOLDIERTYPE *pTeamSoldier; + + cnt = gTacticalStatus.Team[ MILITIA_TEAM ].bFirstID; + + for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ MILITIA_TEAM ].bLastID; cnt++, pTeamSoldier++) + { + if ( pTeamSoldier->bActive && pTeamSoldier->bInSector && pTeamSoldier->bLife > 0 ) + { + + //CREATURE_IMMOBILE = 2 + if ( (pTeamSoldier->bMobility != 2) && (pTeamSoldier->bActionPoints >= MinPtsToMove(pTeamSoldier)) ) + { + //SEARCH_GENERAL_ITEMS=0 + pTeamSoldier->bAction = SearchForItems( pTeamSoldier, 0, pTeamSoldier->inv[HANDPOS].usItem ); + + pTeamSoldier->usNextActionData = SearchForItems( pTeamSoldier, 0, pTeamSoldier->inv[HANDPOS].usItem ); + + + //if ( pTeamSoldier->usNextActionData != NOWHERE ) + { + pTeamSoldier->bNextAction = AI_ACTION_PICKUP_ITEM; + //pTeamSoldier->usActionData = ANIM_STAND; + } + + if (pTeamSoldier->bAction == AI_ACTION_PICKUP_ITEM) + { + // the item pool index was stored in the special data field + pTeamSoldier->uiPendingActionData1 = pTeamSoldier->iNextActionSpecialData; + } + + + + + + //if (pTeamSoldier->bAction != AI_ACTION_NONE) + //{ + // return( pTeamSoldier->bAction ); + //} + } + + + } + } + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + } + break; + + case( MILCON_MENU_CANCEL ): + { + //Cancel + //ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"Cancel" ); + + // stop showing menu + fShowMilitiaControlMenu = FALSE; + giAssignHighLine = -1; + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + + // reset list of characters + ResetSelectedListForMapScreen( ); + } + break; + } + } + + gfRenderPBInterface = TRUE; + } + else if( iReason & MSYS_CALLBACK_REASON_RBUTTON_UP ) + { + //if( ( fShowTalkToAllMenu ) ) + //{ + // fShowTalkToAllMenu = FALSE; + + // // rerender tactical stuff + // gfRenderPBInterface = TRUE; + + // // set dirty flag + // fTeamPanelDirty = TRUE; + // fMapScreenBottomDirty = TRUE; + + // return; + //} + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// +// +//void CreateTalkToAllBox( void ) +//{ +// UINT32 hStringHandle; +// UINT32 uiCounter; +// +// // will create attribute pop up menu for mapscreen assignments +// +// TalkToAllPosition.iX = OrigTalkToAllPosition.iX; +// +// if( giBoxY != 0 ) +// { +// TalkToAllPosition.iY = giBoxY + ( MILCON_MENU_ALL * GetFontHeight( MAP_SCREEN_FONT ) ); +// } +// +// // create basic box +// CreatePopUpBox(&ghTalkToAllBox, TalkToAllDimensions, TalkToAllPosition, (POPUP_BOX_FLAG_CLIP_TEXT|POPUP_BOX_FLAG_CENTER_TEXT|POPUP_BOX_FLAG_RESIZE )); +// +// // which buffer will box render to +// SetBoxBuffer(ghTalkToAllBox, FRAME_BUFFER); +// +// // border type? +// SetBorderType(ghTalkToAllBox,guiPOPUPBORDERS); +// +// // background texture +// SetBackGroundSurface(ghTalkToAllBox, guiPOPUPTEX); +// +// // margin sizes +// SetMargins(ghTalkToAllBox, 6, 6, 4, 4 ); +// +// // space between lines +// SetLineSpace(ghTalkToAllBox, 2); +// +// // set current box to this one +// SetCurrentBox( ghTalkToAllBox ); +// +// +// // add strings for box +// for(uiCounter=0; uiCounter < MAX_TTALL_STRING_COUNT; uiCounter++) +// { +// AddMonoString(&hStringHandle, pTalkToAllMenuStrings[uiCounter]); +// +// // make sure it is unhighlighted +// UnHighLightLine(hStringHandle); +// } +// +// // set font type +// SetBoxFont(ghTalkToAllBox, MAP_SCREEN_FONT); +// +// // set highlight color +// SetBoxHighLight(ghTalkToAllBox, FONT_WHITE); +// +// // unhighlighted color +// SetBoxForeground(ghTalkToAllBox, FONT_LTGREEN); +// +// // background color +// SetBoxBackground(ghTalkToAllBox, FONT_BLACK); +// +// // shaded color..for darkened text +// SetBoxShade( ghTalkToAllBox, FONT_GRAY7 ); +// +// // resize box to text +// ResizeBoxToText( ghTalkToAllBox ); +// +// DetermineMilitiaControlBoxPositions( ); +// +//} +// +// +// +// +//void CreateDestroyMouseRegionsForTalkToAllMenu( void ) +//{ +// static BOOLEAN fCreated = FALSE; +// UINT32 iCounter = 0; +// INT32 iFontHeight = 0; +// INT32 iBoxXPosition = 0; +// INT32 iBoxYPosition = 0; +// SGPPoint pPosition; +// INT32 iBoxWidth = 0; +// SGPRect pDimensions; +// +// // will create/destroy mouse regions for the map screen assignment main menu +// +// if( ( fShowTalkToAllMenu == TRUE ) && ( fCreated == FALSE ) ) +// { +// +// if( ( fShowTalkToAllMenu ) && ( guiCurrentScreen == MAP_SCREEN ) ) //laltodo +// { +// SetBoxPosition( ghTalkToAllBox, TalkToAllPosition ); +// } +// +// HandleShadingOfLinesForTalkToAllMenu( ); +// +// CheckAndUpdateTacticalMilitiaControlPopUpPositions( ); +// +// // grab height of font +// iFontHeight = GetLineSpace( ghTalkToAllBox ) + GetFontHeight( GetBoxFont( ghTalkToAllBox ) ); +// +// // get x.y position of box +// GetBoxPosition( ghTalkToAllBox, &pPosition); +// +// // grab box x and y position +// iBoxXPosition = pPosition.iX; +// iBoxYPosition = pPosition.iY; +// +// // get dimensions..mostly for width +// GetBoxSize( ghTalkToAllBox, &pDimensions ); +// SetBoxSecondaryShade( ghTalkToAllBox, FONT_YELLOW ); +// +// // get width +// iBoxWidth = pDimensions.iRight; +// +// SetCurrentBox( ghTalkToAllBox ); +// +// // define regions +// for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghTalkToAllBox ); iCounter++ ) +// { +// // add mouse region for each line of text..and set user data +// +// +// MSYS_DefineRegion( &gTalkToAllMenuRegion[ iCounter ], ( INT16 )( iBoxXPosition ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghTalkToAllBox ) + ( iFontHeight ) * iCounter ), ( INT16 )( iBoxXPosition + iBoxWidth ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghTalkToAllBox ) + ( iFontHeight ) * ( iCounter + 1 ) ), MSYS_PRIORITY_HIGHEST - 3 , +// MSYS_NO_CURSOR, TalkToAllMenuMvtCallBack, TalkToAllMenuBtnCallback ); +// +// // set user defines +// MSYS_SetRegionUserData( &gTalkToAllMenuRegion[ iCounter ], 0, iCounter ); +// } +// +// // created +// fCreated = TRUE; +// +// // unhighlight all strings in box +// UnHighLightBox( ghTalkToAllBox ); +// +// } +// else if( ( ( fShowMilitiaControlMenu == FALSE ) || ( fShowTalkToAllMenu == FALSE ) ) && ( fCreated == TRUE ) ) +// { +// // destroy +// for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghTalkToAllBox ); iCounter++ ) +// { +// MSYS_RemoveRegion( &gTalkToAllMenuRegion[ iCounter ] ); +// } +// +// // stop showing TalkToAll menu +// if( fShowMilitiaControlMenu == FALSE ) +// { +// fShowTalkToAllMenu = FALSE; +// } +// +// RestorePopUpBoxes( ); +// +// fMapPanelDirty = TRUE; +// fCharacterInfoPanelDirty= TRUE; +// fTeamPanelDirty = TRUE; +// fMapScreenBottomDirty = TRUE; +// HideBox( ghTalkToAllBox ); +// SetRenderFlags( RENDER_FLAG_FULL ); +// +// // not created +// fCreated = FALSE; +// +// if ( fShowMilitiaControlMenu ) +// { +// // remove highlight on the parent menu +// UnHighLightBox( ghMilitiaControlBox ); +// } +// } +//} +// +//void TalkToAllMenuMvtCallBack(MOUSE_REGION * pRegion, INT32 iReason ) +//{ +// // mvt callback handler for assignment region +// INT32 iValue = -1; +// +// iValue = MSYS_GetRegionUserData( pRegion, 0 ); +// +// //if( HandleAssignmentExpansionAndHighLightForTalkToAllMenu( ) == TRUE ) +// //{ +// // return; +// //} +// +// if (iReason & MSYS_CALLBACK_REASON_GAIN_MOUSE ) +// { +// // highlight string +// +// // do not highlight current balance +// if( GetBoxShadeFlag( ghTalkToAllBox, iValue ) == FALSE ) +// { +// // get the string line handle +// HighLightBoxLine( ghTalkToAllBox, iValue ); +// } +// } +// else if (iReason & MSYS_CALLBACK_REASON_LOST_MOUSE ) +// { +// // unhighlight all strings in box +// UnHighLightBox( ghTalkToAllBox ); +// } +//} +// +// +// +//void TalkToAllMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason ) +//{ +// // btn callback handler for assignment region +// INT32 iValue = -1; +// SOLDIERTYPE * pSoldier = NULL; +// +// iValue = MSYS_GetRegionUserData( pRegion, 0 ); +// +// //if( ( iReason & MSYS_CALLBACK_REASON_LBUTTON_DWN ) || ( iReason & MSYS_CALLBACK_REASON_RBUTTON_DWN ) ) +// //{ +// // if ( (guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) && !fShowMapInventoryPool ) +// // { +// // UnMarkButtonDirty( giMapBorderButtons[ MAP_BORDER_TOWN_BTN ] ); +// // } +// //} +// +// if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP) +// { +// switch( iValue ) +// { +// case( TTALL_MENU_ATTACK ): +// { +// // Attack !!! +// ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"Attack" ); +// +// pTMilitiaSoldier->bOrders = SEEKENEMY; +// pTMilitiaSoldier->bAttitude = AGGRESSIVE; +// +// // stop showing menu +// fShowMilitiaControlMenu = FALSE; +// //fShowTalkToAllMenu = FALSE; +// giAssignHighLine = -1; +// } +// break; +// +// case( TTALL_MENU_HOLD ): +// { +// //Hold Position !!! +// ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"Hold Position" ); +// +// pTMilitiaSoldier->bOrders = STATIONARY; +// //pTMilitiaSoldier->bAttitude = DEFENSIVE; +// +// // stop showing menu +// fShowMilitiaControlMenu = FALSE; +// //fShowTalkToAllMenu = FALSE; +// giAssignHighLine = -1; +// } +// break; +// +// case( TTALL_MENU_RETREAT ): +// { +// // Retreat !!! +// ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"Retreat" ); +// +// pTMilitiaSoldier->bOrders = FARPATROL; +// //pTMilitiaSoldier->bAttitude = DEFENSIVE; +// +// // set up next action to run away +// pTMilitiaSoldier->usNextActionData = FindSpotMaxDistFromOpponents( pTMilitiaSoldier ); +// if ( pTMilitiaSoldier->usNextActionData != NOWHERE ) +// { +// pTMilitiaSoldier->bNextAction = AI_ACTION_RUN_AWAY; +// pTMilitiaSoldier->usActionData = ANIM_STAND; +// //return( AI_ACTION_STOP_COWERING ); +// } +// +// // stop showing menu +// fShowMilitiaControlMenu = FALSE; +// //fShowTalkToAllMenu = FALSE; +// giAssignHighLine = -1; +// } +// break; +// +// +// case( TTALL_MENU_COMETOME ): +// { +// ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"Come to me" ); +// +// UINT8 cnt; +// SOLDIERTYPE * pTeamSoldier; +// INT16 sActionGridNo, sGridNo, sAdjustedGridNo; +// UINT8 ubDirection; +// +// cnt = gTacticalStatus.Team[ MILITIA_TEAM ].bFirstID; +// +// for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ MILITIA_TEAM ].bLastID; cnt++, pTeamSoldier++) +// { +// if ( pTeamSoldier->bActive && pTeamSoldier->bInSector && pTeamSoldier->bLife > 0 ) +// { +// +// if ( GetSoldier( &pSoldier, gusSelectedSoldier ) ) +// { +// // OK, find an adjacent gridno.... +// sGridNo = pSoldier->sGridNo; +// +// // See if we can get there to punch +// sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); +// if ( sActionGridNo != -1 ) +// { +// // SEND PENDING ACTION +// //pTMilitiaSoldier->ubPendingAction = MERC_STEAL; +// pTeamSoldier->sPendingActionData2 = pSoldier->sGridNo; +// pTeamSoldier->bPendingActionData3 = ubDirection; +// pTeamSoldier->ubPendingActionAnimCount = 0; +// +// // CHECK IF WE ARE AT THIS GRIDNO NOW +// if ( pTeamSoldier->sGridNo != sActionGridNo ) +// { +// // WALK UP TO DEST FIRST +// SendGetNewSoldierPathEvent( pTeamSoldier, sActionGridNo, pTeamSoldier->usUIMovementMode ); +// } +// } +// } +// } +// } +// +// // stop showing menu +// fShowMilitiaControlMenu = FALSE; +// //fShowTalkToAllMenu = FALSE; +// giAssignHighLine = -1; +// } +// break; +// +// case( TTALL_MENU_GETDOWN ): +// { +// // Get Down !!! +// ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"Get Down" ); +// +// SendChangeSoldierStanceEvent( pTMilitiaSoldier, ANIM_PRONE ); +// //SendChangeSoldierStanceEvent( pTMilitiaSoldier, ANIM_CROUCH ); +// +// // stop showing menu +// fShowMilitiaControlMenu = FALSE; +// //fShowTalkToAllMenu = FALSE; +// giAssignHighLine = -1; +// } +// break; +// +// case( TTALL_MENU_CANCEL ): +// { +// //Cancel +// ScreenMsg( FONT_WHITE, MSG_INTERFACE, L"Cancel" ); +// +// // stop showing menu +// fShowTalkToAllMenu = FALSE; +// +// // unhighlight the assignment box +// UnHighLightBox( ghMilitiaControlBox ); +// +// // reset list of characters +// ResetSelectedListForMapScreen( ); +// gfRenderPBInterface = TRUE; +// } +// break; +// } +// // set dirty flag +// fTeamPanelDirty = TRUE; +// fMapScreenBottomDirty = TRUE; +// } +//} +// +// + + + + + + + + + + + + +//void HandleShadingOfLinesForTalkToAllMenu( void ) +//{ +// SOLDIERTYPE *pSoldier = NULL; +// INT32 iCounter = 0; +// +// +// // check if valid +// if( ( fShowTalkToAllMenu == FALSE ) || ( ghTalkToAllBox == - 1 ) ) +// { +// return; +// } +// +// //pSoldier = GetSelectedAssignSoldier( FALSE ); +// +// //// can character practise? +// //if( CanCharacterPractise( pSoldier ) == FALSE ) +// //{ +// // ShadeStringInBox( ghTalkToAllBox, TalkToAll_MENU_SELF ); +// //} +// //else +// //{ +// // UnShadeStringInBox( ghTalkToAllBox, TalkToAll_MENU_SELF ); +// //} +// +// +// return; +//} + + diff --git a/Tactical/Militia Control.h b/Tactical/Militia Control.h index 9fbae1418..0165ecdf0 100644 --- a/Tactical/Militia Control.h +++ b/Tactical/Militia Control.h @@ -1,6 +1,11 @@ #ifndef __MILITIA_CONTROL_H #define __MILITIA_CONTROL_H +#include "Types.h" +#include "Soldier Control.h" +#include "mousesystem.h" +#include "Strategic Movement.h" + void PrepareMilitiaForTactical(); void RemoveMilitiaFromTactical(); void ResetMilitia(); @@ -8,4 +13,19 @@ void HandleMilitiaPromotions(); extern BOOLEAN gfStrategicMilitiaChangesMade; +extern INT32 ghMilitiaControlBox; +//extern INT32 ghTalkToAllBox; + +extern BOOLEAN fFirstClickInMilitiaControlScreenMask; + +// figure out the assignment menu pop up box positions +void DetermineMilitiaControlBoxPositions( void ); + +// set x,y position in tactical +void SetTacticalPopUpMilitiaControlBoxXY( SOLDIERTYPE *pSoldier ); + +BOOLEAN CreateDestroyMilitiaControlPopUpBoxes( void ); + +BOOLEAN CheckIfRadioIsEquipped( void ); + #endif \ No newline at end of file diff --git a/Tactical/Rain.cpp b/Tactical/Rain.cpp index ea360f594..5a8d94f57 100644 --- a/Tactical/Rain.cpp +++ b/Tactical/Rain.cpp @@ -151,7 +151,7 @@ BOOLEAN IsItAllowedToRenderRain() { if( !gfAllowRain )return FALSE; - if( !( guiEnvWeather & WEATHER_FORECAST_THUNDERSHOWERS | WEATHER_FORECAST_SHOWERS ) )return FALSE; + if( !( guiEnvWeather & (WEATHER_FORECAST_THUNDERSHOWERS | WEATHER_FORECAST_SHOWERS) ) )return FALSE; if( guiCurrentScreen != GAME_SCREEN && guiCurrentScreen != SHOPKEEPER_SCREEN ) return FALSE; @@ -198,7 +198,7 @@ void ResetRain() void GenerateRainDropsList() { - guiCurrMaxAmountOfRainDrops = (UINT32)(BASE_MAXIMUM_DROPS * gbCurrentRainIntensity); + guiCurrMaxAmountOfRainDrops = (UINT32)BASE_MAXIMUM_DROPS * gbCurrentRainIntensity; pRainDrops = (TRainDrop *)MemAlloc( sizeof( TRainDrop ) * guiCurrMaxAmountOfRainDrops ); memset( pRainDrops, 0, sizeof( TRainDrop ) * guiCurrMaxAmountOfRainDrops ); diff --git a/Tactical/Real Time Input.cpp b/Tactical/Real Time Input.cpp index 136f4de97..4b1f67e67 100644 --- a/Tactical/Real Time Input.cpp +++ b/Tactical/Real Time Input.cpp @@ -70,6 +70,7 @@ extern BOOLEAN fIgnoreLeftUp; extern UINT32 guiCurrentEvent; extern UINT32 guiCurrentUICursor; extern void DetermineWhichAssignmentMenusCanBeShown( void ); +extern void DetermineWhichMilitiaControlMenusCanBeShown( void ); extern BOOLEAN gfIgnoreOnSelectedGuy; extern INT16 gsOverItemsGridNo; extern INT16 gsOverItemsLevel; @@ -1023,34 +1024,38 @@ void QueryRTRightButton( UINT32 *puiNewEvent ) case TALKCURSOR_MODE: case MOVE_MODE: - if ( GetSoldier( &pSoldier, gusSelectedSoldier ) ) - { - if ( ( guiUIFullTargetFlags & OWNED_MERC ) && ( guiUIFullTargetFlags & VISIBLE_MERC ) && !( guiUIFullTargetFlags & DEAD_MERC )&&!( pSoldier ? pSoldier->uiStatusFlags & SOLDIER_VEHICLE : 0 ) ) - { - //if( pSoldier->bAssignment >= ON_DUTY ) - { - PopupAssignmentMenuInTactical( pSoldier ); - fClickHoldIntercepted = TRUE; - } - break; - } - else - { - fShowAssignmentMenu = FALSE; - CreateDestroyAssignmentPopUpBoxes( ); - DetermineWhichAssignmentMenusCanBeShown( ); - } + if ( GetSoldier( &pSoldier, gusSelectedSoldier ) ) + { + if ( ( guiUIFullTargetFlags & OWNED_MERC ) && ( guiUIFullTargetFlags & VISIBLE_MERC ) && !( guiUIFullTargetFlags & DEAD_MERC )&&!( pSoldier ? pSoldier->uiStatusFlags & SOLDIER_VEHICLE : 0 ) ) + { + //if( pSoldier->bAssignment >= ON_DUTY ) + { + PopupAssignmentMenuInTactical( pSoldier ); + fClickHoldIntercepted = TRUE; + } + break; + } + else + { + fShowAssignmentMenu = FALSE; + CreateDestroyAssignmentPopUpBoxes( ); + DetermineWhichAssignmentMenusCanBeShown( ); + + fShowMilitiaControlMenu = FALSE; + CreateDestroyMilitiaControlPopUpBoxes( ); + DetermineWhichMilitiaControlMenusCanBeShown( ); + } + + // ATE: + if ( !fClickHoldIntercepted ) + { + *puiNewEvent = U_MOVEMENT_MENU; + fClickHoldIntercepted = TRUE; + } + break; + } + } - // ATE: - if ( !fClickHoldIntercepted ) - { - *puiNewEvent = U_MOVEMENT_MENU; - fClickHoldIntercepted = TRUE; - } - break; - } - } - if ( gCurrentUIMode == ACTION_MODE || gCurrentUIMode == TALKCURSOR_MODE ) { PauseRT( FALSE ); diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 63ea50388..86e29c1fb 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -93,6 +93,8 @@ UINT8 gubMilitiaTurnSpeedUpFactor = 1; UINT8 gubCivTurnSpeedUpFactor = 1; //turnspeed +extern BOOLEAN fAllowTacticalMilitiaCommand; //lal + extern INT16 DirIncrementer[8]; #define PALETTEFILENAME "BINARYDATA\\ja2pal.dat" @@ -10755,6 +10757,7 @@ void MercStealFromMerc( SOLDIERTYPE *pSoldier, SOLDIERTYPE *pTarget ) } } +SOLDIERTYPE *pTMilitiaSoldier; BOOLEAN PlayerSoldierStartTalking( SOLDIERTYPE *pSoldier, UINT8 ubTargetID, BOOLEAN fValidate ) { INT16 sFacingDir, sXPos, sYPos, sAPCost; @@ -10795,28 +10798,45 @@ BOOLEAN PlayerSoldierStartTalking( SOLDIERTYPE *pSoldier, UINT8 ubTargetID, BOOL // Deduct points from our guy.... DeductPoints( pSoldier, sAPCost, 0 ); - ConvertGridNoToXY( pTSoldier->sGridNo, &sXPos, &sYPos ); + if ( !(gTacticalStatus.uiFlags & INCOMBAT) || (gTacticalStatus.uiFlags & REALTIME) ) //lal + { + ConvertGridNoToXY( pTSoldier->sGridNo, &sXPos, &sYPos ); - // Get direction from mouse pos - sFacingDir = GetDirectionFromXY( sXPos, sYPos, pSoldier ); + // Get direction from mouse pos + sFacingDir = GetDirectionFromXY( sXPos, sYPos, pSoldier ); - // Set our guy facing - SendSoldierSetDesiredDirectionEvent( pSoldier, sFacingDir ); + // Set our guy facing + SendSoldierSetDesiredDirectionEvent( pSoldier, sFacingDir ); - // Set NPC facing - SendSoldierSetDesiredDirectionEvent( pTSoldier, gOppositeDirection[ sFacingDir ] ); - - // Stop our guys... - EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection ); + // Set NPC facing + SendSoldierSetDesiredDirectionEvent( pTSoldier, gOppositeDirection[ sFacingDir ] ); + // Stop our guys... + EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection ); + } + + pTMilitiaSoldier = pTSoldier; //lal + + //lal // ATE; Check for normal civs... if ( GetCivType( pTSoldier ) != CIV_TYPE_NA ) { - StartCivQuote( pTSoldier ); - return( FALSE ); + //lal + if ( ( pTSoldier->bTeam == MILITIA_TEAM ) && ( fAllowTacticalMilitiaCommand == TRUE ) ) + { + PopupMilitiaControlMenu( pTSoldier ); + return( FALSE ); + } + else + { + StartCivQuote( pTSoldier ); + return( FALSE ); + } } + + // Are we an EPC that is being escorted? if ( pTSoldier->ubProfile != NO_PROFILE && pTSoldier->ubWhatKindOfMercAmI == MERC_TYPE__EPC ) { diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index 380bee5fc..f46cd7a85 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -227,6 +227,7 @@ UINT8 gubCheatLevel = STARTING_CHEAT_LEVEL; extern void DetermineWhichAssignmentMenusCanBeShown( void ); +extern void DetermineWhichMilitiaControlMenusCanBeShown( void ); //lal void GetTBMouseButtonInput( UINT32 *puiNewEvent ) { @@ -4985,3 +4986,16 @@ void PopupAssignmentMenuInTactical( SOLDIERTYPE *pSoldier ) fFirstClickInAssignmentScreenMask = TRUE; gfIgnoreScrolling = TRUE; } + +//lal +void PopupMilitiaControlMenu( SOLDIERTYPE *pSoldier ) +{ + // do something + fShowMilitiaControlMenu = TRUE; + CreateDestroyMilitiaControlPopUpBoxes( ); + SetTacticalPopUpMilitiaControlBoxXY( pSoldier ); + DetermineMilitiaControlBoxPositions(); + DetermineWhichMilitiaControlMenusCanBeShown( ); + fFirstClickInMilitiaControlScreenMask = TRUE; + gfIgnoreScrolling = TRUE; +} diff --git a/Utils/Cursors.cpp b/Utils/Cursors.cpp index 80895fb3b..17617987c 100644 --- a/Utils/Cursors.cpp +++ b/Utils/Cursors.cpp @@ -16,6 +16,10 @@ #include "Cursor Control.h" #endif +//aim +extern UINT8 gubShowActionPointsInRed; +UINT8 gpShadesFromWhiteToRed[] = {FONT_MCOLOR_WHITE, FONT_MCOLOR_DKWHITE, FONT_MCOLOR_DKGRAY, FONT_MCOLOR_DKRED, FONT_MCOLOR_RED }; +//aim #define NUM_MOUSE_LEVELS 2 @@ -1451,6 +1455,16 @@ void DrawMouseText( ) SetFontBackground( FONT_MCOLOR_BLACK ); SetFontForeground( FONT_MCOLOR_WHITE ); SetFontShadow( DEFAULT_SHADOW ); + + //aim + if ( gubShowActionPointsInRed ) + { + SetFontForeground( gpShadesFromWhiteToRed[ gubShowActionPointsInRed - 1 ] ); + gubShowActionPointsInRed = 0; + } + else + SetFontForeground( FONT_MCOLOR_WHITE ); + //aim } } else @@ -1460,6 +1474,14 @@ void DrawMouseText( ) if ( gfUIDisplayActionPointsBlack ) { + //aim + if ( gubShowActionPointsInRed ) + { + SetFontForeground( gpShadesFromWhiteToRed[ gubShowActionPointsInRed - 1 ] ); + gubShowActionPointsInRed = 0; + } + else + //aim SetFontForeground( FONT_MCOLOR_WHITE ); SetFontShadow( DEFAULT_SHADOW ); } diff --git a/Utils/Text.h b/Utils/Text.h index 3d5f0fa30..4586254cc 100644 --- a/Utils/Text.h +++ b/Utils/Text.h @@ -14,6 +14,8 @@ extern UINT16 WeaponType[MAXITEMS][30]; extern UINT16 Message[][STRING_LENGTH]; extern UINT16 TeamTurnString[][STRING_LENGTH]; +extern STR16 pMilitiaControlMenuStrings[]; //lal +//extern STR16 pTalkToAllMenuStrings[]; extern STR16 pAssignMenuStrings[]; extern STR16 pTrainingStrings[]; extern STR16 pTrainingMenuStrings[];