//****************************************************************************************// // // Ecounter 3 Group 1 // // MISSION: Mc2_10 // Convoy that goes to the Gulag when Objective 2 is complete. // // //****************************************************************************************// fsm mc2_10_EC3_Grp1; var static WorldPosition startPosition; static PatrolState gulagPatrolState, AirFieldPatrolState; static PatrolPath gulagPatrolPath, AirFieldPatrolPath; static boolean willRequestHelp; static real lastHelpRequestTime; static real helpRequestFrequency; static real attackerHelpRadius; static real defenderHelpRadius; static boolean test_Covoy_go_1, test_Covoy_Go_2; static integer numFunctionalWeapons; static integer[20] weaponList; //**************************************************************************************** function init; code //setDebugWindow(-1, -1); //--------------------------- // Grab his start position... getObjectPosition(-1, startPosition); //------------------- // Look for movers... setTargetPriority(0, TARGET_PRIORITY_NONE, 0, 0, 0); test_Covoy_go_1 = False; test_Covoy_go_2 = False; //------------------------------------------- // Setup the Patrol here... //XL AirFieldPatrolStateStart AirFieldPatrolState[0] = PATROL_TYPE_LINEAR; AirFieldPatrolState[1] = 12; //?num points AirFieldPatrolState[2] = 1; //?num cycles AirFieldPatrolState[3] = PATROL_DIRECTION_FORWARD; AirFieldPatrolState[4] = -1; //reset cur point AirFieldPatrolState[5] = -1; //reset cur cycle AirFieldPatrolState[6] = CONTACT_CRITERIA_NONE; AirFieldPatrolPath[0, 0] = -1728.000; AirFieldPatrolPath[0, 1] = 2112.000; AirFieldPatrolPath[1, 0] = -1728.000; AirFieldPatrolPath[1, 1] = -64.000; AirFieldPatrolPath[2, 0] = 192.000; AirFieldPatrolPath[2, 1] = -149.000; AirFieldPatrolPath[3, 0] = 192.000; AirFieldPatrolPath[3, 1] = 960.000; AirFieldPatrolPath[4, 0] = 960.000; AirFieldPatrolPath[4, 1] = 1002.667; AirFieldPatrolPath[5, 0] = 960.000; AirFieldPatrolPath[5, 1] = 1557.330; AirFieldPatrolPath[6, 0] = 1728.000; AirFieldPatrolPath[6, 1] = 1642.667; AirFieldPatrolPath[7, 0] = 1770.667; AirFieldPatrolPath[7, 1] = 2496.000; AirFieldPatrolPath[8, 0] = 2496.000; AirFieldPatrolPath[8, 1] = 2538.667; AirFieldPatrolPath[9, 0] = 2496.000; AirFieldPatrolPath[9, 1] = 3861.333; AirFieldPatrolPath[10, 0] = 2880.000; AirFieldPatrolPath[10, 1] = 3904.000; AirFieldPatrolPath[11, 0] = 2922.667; AirFieldPatrolPath[11, 1] = 4672.000; //XLs AirFieldPatrolPath end //------------------------------------------- // Setup the Patrol here... //XL gulagPatrolState Start gulagPatrolState[0] = PATROL_TYPE_LINEAR; gulagPatrolState[1] = 6; //?num points gulagPatrolState[2] = 1; //?num cycles gulagPatrolState[3] = PATROL_DIRECTION_FORWARD; gulagPatrolState[4] = -1; //reset cur point gulagPatrolState[5] = -1; //reset cur cycle gulagPatrolState[6] = CONTACT_CRITERIA_NONE; gulagPatrolPath[0, 0] = -3648.000; gulagPatrolPath[0, 1] = 106.667; gulagPatrolPath[1, 0] = -3605.333; gulagPatrolPath[1, 1] = 448.000; gulagPatrolPath[2, 0] = -2880.000; gulagPatrolPath[2, 1] = 448.000; gulagPatrolPath[3, 0] = -2837.333; gulagPatrolPath[3, 1] = -21.330; gulagPatrolPath[4, 0] = -1728.000; gulagPatrolPath[4, 1] = -64.000; gulagPatrolPath[5, 0] = -1728.000; gulagPatrolPath[5, 1] = 2112.000; //gulagPatrolPath[6, 0] = -1685.333; //gulagPatrolPath[6, 1] = 2752.000; //XLs gulagPatrolPath end willRequestHelp = False; //?true or false helpRequestFrequency = 20.0; //?in secs attackerHelpRadius = 200; //?in meters defenderHelpRadius = 225; //?in meters lastHelpRequestTime = -100.0; endfunction; //---------------------------------------------------------------------------------------- function setWillRequestHelp (boolean setting); code if (setting and (not willRequestHelp)) then lastHelpRequestTime = 0.0; endif; willRequestHelp = setting; endfunction; //---------------------------------------------------------------------------------------- function update : integer; var boolean processingPilotEvents; boolean thinking; integer pilotEventID; integer pilotState; integer[20] pilotEventParams; integer curTarget; real curTime; real[3] myPos; real[3] attackerPos; real distanceToAttacker; integer curStateHandle; code curTime = getTime; //----------------------------------- // curStateHandle = getCurrentStateHandle; //----------------------------------- // Trigger for Convoy to Move to The Gulag if (Convoy_Go_1) then if (Not test_Covoy_go_1) then test_Covoy_go_1 = true; trans toGulag; endif; endif; //----------------------------------- // Trigger for Convoy to Move to the AirField if (Convoy_Go_2) then if (Not test_Covoy_go_2) then test_Covoy_go_2 = true; trans toAirField; endif; endif; //-------------------------------------------------- // Process the pilot events since the last update... numFunctionalWeapons = getWeapons(weaponList, 1); if (numFunctionalWeapons == 0) then //trans noWeapons; endif; processingPilotEvents = TRUE; while (processingPilotEvents) do pilotEventID = getNextPilotEvent(pilotEventParams); if (pilotEventID == PILOT_EVENT_NONE) then processingPilotEvents = FALSE; else switch (pilotEventID) case PILOT_EVENT_TARGETED: curTarget = getTarget(-1); if (lastHelpRequestTime < (curTime - helpRequestFrequency)) then lastHelpRequestTime = curTime; if (willRequestHelp) then //distanceToAttacker = distanceToObject(-1, pilotEventParams[0]); getObjectPosition(pilotEventParams[0], attackerPos); getObjectPosition(-1, myPos); requestHelp(pilotEventParams[0], myPos, attackerHelpRadius, attackerPos, defenderHelpRadius, 1); endif; endif; numFunctionalWeapons = getWeapons(weaponList, 0); endcase; case PILOT_EVENT_ATTACK_ORDER: endcase; case PILOT_EVENT_FIRED_WEAPON: endcase; endswitch; endif; endwhile; return(0); endfunction; //---------------------------------------------------------------------------------------- state noWeapons; code setDebugString(-1, 3, " NO WEAPONS "); if (objectClass(-1) == 2) then coreEject; else corePower(false); endif; endstate; //---------------------------------------------------------------------------------------- state toGulag; var worldposition gulagGuard; code update; setDebugString(-1, 3, " TO Gulag "); corePatrol (gulagPatrolState, gulagPatrolPath, -1); gotTOGulag = True; setDebugString(-1, 3, " Waiting 2 "); //************************************** //DEBUG PLACEHOLDER Tells convoy to go to AirField //Convoy_Go_2 = True; gulagGuard[0] = -1685.333; gulagGuard[1] = 2752.000; gulagGuard[2] = 0.0; setDebugString(-1, 3, "GulagGuard "); coreGuard (gulagGuard, -1, -1); endstate; //---------------------------------------------------------------------------------------- state toAirField; code update; setDebugString(-1, 3, " TO AirField "); corePatrol (AirFieldPatrolState, AirFieldPatrolPath, -1); endstate; //---------------------------------------------------------------------------------------- state start; code update; setDebugString(-1, 3, " Waiting "); //****************************************************** //DEBUG PLACEHOLDER Tells Convoy to got to the GUlag //Convoy_Go_1 = True; endstate; //---------------------------------------------------------------------------------------- endfsm. //****************************************************************************************