I figured that some people might be interested in taking a look at my scripts, as most of the source code for TB3 won't be available with the mod, I will post my scripts here beforehand. I decided to post the new Custom Mission script for the new STL Tools first... Here we go with the script file: ////////////////////////////////////////////////////////////////////////// // -----------------------------------------------------[SCRIPT FILE]-- // // =/\= Advanced Custom Mission // // -------------------------------------------------------------------- // //////////////////////////////////////////////////////////////////////////
// *********************************************************************** // * * // * =/|\= Context Includes * // * * // ***********************************************************************
CONTEXT
END_CONTEXT
// *********************************************************************** // * * // * =/|\= Variable Definitions * // * * // ***********************************************************************
DEFINITIONS hot_int MISSION_BEGUN hot_int MISSION_END
hot_int BEGIN_MISSION
int PLAYER_TEAM int ENEMY_TEAM int ALLY_TEAM
timer_int tCheckWhetherAllyNeedsHelp END_DEFINITIONS
// *********************************************************************** // * * // * =/|\= Initialize Variables * // * * // *********************************************************************** INITIALIZATION
MISSION_BEGUN = 0; MISSION_END = 0;
PLAYER_TEAM = 1; ENEMY_TEAM = 2; ALLY_TEAM = 3;
BEGIN_MISSION = 1; END_INITIALIZATION
// *********************************************************************** // * * // * =/|\= In Game Events * // * * // ***********************************************************************
////////////////////////////////////////////////////////////////////////// // -------------------------------------------------------------------- // // =/\= Start Mission // // -------------------------------------------------------------------- // ////////////////////////////////////////////////////////////////////////// ACTION Start_Mission
SCRIPT WORLD
BEGIN_MISSION = 0;
DisableAllAITeams(); JukeBoxPlaySpecific( "ST_FireStormBattle2.ogg" ); AllowDamage( -1, true);
Handle hTmpHandle;
for(int i = 0; i < 4; i++) { char buffer[50]; sprintf(buffer, "x_cb_player_%d", (int)i); hTmpHandle = BuildObject(buffer, 3, "Camera_1"); SetRealTeam(hTmpHandle, PLAYER_TEAM); SetPerceivedTeam(hTmpHandle, PLAYER_TEAM); };
for(int i = 0; i < 20; i++) { char buffer1[50]; sprintf(buffer1, "x_cb_enemy_%d", (int)i); hTmpHandle = BuildObject(buffer1, ENEMY_TEAM, "Camera_2");
SetSpecialForcesFlag( hTmpHandle, true); SearchAndDestroy( hTmpHandle ); SetTactics( hTmpHandle, TACTICS_AGGRESSIVE ); //SetCraftVisibleToTeam(hTmpHandle, 1, true); SetSpecialForcesFlag( hTmpHandle, false);
}; for(int i = 0; i < 20; i++) { char buffer1[50]; sprintf(buffer1, "x_cb_ally_%d", (int)i); hTmpHandle = BuildObject(buffer1, ALLY_TEAM, "Camera_3");
SetSpecialForcesFlag( hTmpHandle, true); SearchAndDestroy( hTmpHandle ); SetTactics( hTmpHandle, TACTICS_AGGRESSIVE ); //SetCraftVisibleToTeam(hTmpHandle, 1, true); SetSpecialForcesFlag( hTmpHandle, false); };
SetRelation(1, 3, TEAM_ALLY); SetRelation(3, 1, TEAM_ALLY);
SetRelation(1, 2, TEAM_ENEMY); SetRelation(2, 1, TEAM_ENEMY);
SetRelation(3, 2, TEAM_ENEMY); SetRelation(2, 3, TEAM_ENEMY);
tCheckWhetherAllyNeedsHelp.start( 30.0f ); MISSION_BEGUN = 1; END_SCRIPT
END_ACTION
////////////////////////////////////////////////////////////////////////// // -------------------------------------------------------------------- // // =/\= Assist Ally // // -------------------------------------------------------------------- // ////////////////////////////////////////////////////////////////////////// ACTION Check_Ally
SCRIPT WORLD Handle hTmpHandle1; Handle hTmpHandle2;
tCheckWhetherAllyNeedsHelp.stop();
for (int i = 0; i < CountUnits(ALLY_TEAM); i++) { hTmpHandle1 = GetCraftFromTeamList(ALLY_TEAM, i); if(!UnderAttack(hTmpHandle1)) { SetSpecialForcesFlag(hTmpHandle1, true); SearchAndDestroy(hTmpHandle1); SetSpecialForcesFlag(hTmpHandle1, false); }; };
for (int i = 0; i < CountUnits(PLAYER_TEAM); i++) { hTmpHandle1 = GetCraftFromTeamList(PLAYER_TEAM, i); hTmpHandle2 = GetCraftFromTeamList(ALLY_TEAM, RandomGetUnsigned(CountUnits(ALLY_TEAM))); if(UnderAttack(hTmpHandle1) && !UnderAttack(hTmpHandle2)) { SetSpecialForcesFlag(hTmpHandle2, true); SetCommandWhatWhoVO(hTmpHandle2, CMD_GUARD, hTmpHandle1); SetSpecialForcesFlag(hTmpHandle2, false); break; }; };
tCheckWhetherAllyNeedsHelp.start( 30.0f );
END_SCRIPT
END_ACTION
////////////////////////////////////////////////////////////////////////// // -------------------------------------------------------------------- // // =/\= Mission Success // // -------------------------------------------------------------------- // ////////////////////////////////////////////////////////////////////////// ACTION Mission_Success
SCRIPT WORLD
MISSION_END = 1;
SucceedMission( GetTime() + 6.0 ); ShowChatMessage( 0.5, 0.5, 1.0, "Mission Succeeded!");
END_SCRIPT
END_ACTION
////////////////////////////////////////////////////////////////////////// // -------------------------------------------------------------------- // // =/\= Mission Fail // // -------------------------------------------------------------------- // ////////////////////////////////////////////////////////////////////////// ACTION Mission_Fail
SCRIPT WORLD
MISSION_END = 1; and here's the rule file: ////////////////////////////////////////////////////////////////////////// // -----------------------------------------------------[RULE FILE]---- // // =/\= Simple Mission Template // // -------------------------------------------------------------------- // ////////////////////////////////////////////////////////////////////////// RULES FOR WORLD
// *********************************************************************** // * * // * =/|\= Context Includes * // * * // *********************************************************************** CONTEXT
cbS
END_CONTEXT
////////////////////////////////////////////////////////////////////////// // -------------------------------------------------------------------- // // =/\= Start Mission Rule // // -------------------------------------------------------------------- // //////////////////////////////////////////////////////////////////////////
RULE StartGameRule if ( BEGIN_MISSION ) then Start_Mission END_RULE
// *********************************************************************** // * * // * =/|\= In Game Events * // * * // ***********************************************************************
////////////////////////////////////////////////////////////////////////// // -------------------------------------------------------------------- // // =/\= Assist Rule // // -------------------------------------------------------------------- // ////////////////////////////////////////////////////////////////////////// RULE AssistAllyRule if( !MISSION_END && MISSION_BEGUN && tCheckWhetherAllyNeedsHelp ) then Check_Ally END_RULE
////////////////////////////////////////////////////////////////////////// // -------------------------------------------------------------------- // // =/\= Mission Failure Rule // // -------------------------------------------------------------------- // //////////////////////////////////////////////////////////////////////////
RULE MissionFailureRule if( ALWAYS_EVALUATE && !MISSION_END && MISSION_BEGUN && CountUnits(PLAYER_TEAM) == 0) then Mission_Fail END_RULE
////////////////////////////////////////////////////////////////////////// // -------------------------------------------------------------------- // // =/\= Mission Success Rule // // -------------------------------------------------------------------- // ////////////////////////////////////////////////////////////////////////// RULE MissionSuccessRule if( ALWAYS_EVALUATE && !MISSION_END && MISSION_BEGUN && CountUnits(ENEMY_TEAM) == 0 ) then Mission_Success END_RULE
This is excellent gdata, exactly what file front needs, I know myself how complex scripting can get, So in this script you have an enemy an ally and yourself, and a timer to check if the allied fleet is in trouble, just as an afterthought, you could include a mission fail rule that fires with the destruction of the allies, this would give the player more of an incentive to help them!