//****************************************************************************************// // // Ecounter 3 Group 1 // // MISSION: Mc2_10 // Convoy that goes to the Gulag when Objective 2 is complete. // // //****************************************************************************************// fsm mc2_10_EC3_Conv3; 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; static real conTimer, conTimer2; //**************************************************************************************** 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; conTimer = -1; conTimer2 = -1; //------------------------------------------- // Setup the Patrol here... //XL AirFieldPatrolStateStart AirFieldPatrolState[0] = PATROL_TYPE_LINEAR; AirFieldPatrolState[1] = 8; //?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] = startPosition[0] + 5760; AirFieldPatrolPath[0 ,1] = startPosition[1] + 470; AirFieldPatrolPath[1 ,0] = startPosition[0] + 5760; AirFieldPatrolPath[1 ,1] = startPosition[1] + 470; AirFieldPatrolPath[2 ,0] = startPosition[0] + 5760; AirFieldPatrolPath[2 ,1] = startPosition[1] - 1791; AirFieldPatrolPath[3 ,0] = startPosition[0] + 7680; AirFieldPatrolPath[3 ,1] = startPosition[1] - 1791; AirFieldPatrolPath[4 ,0] = startPosition[0] + 8448; AirFieldPatrolPath[4 ,1] = startPosition[1] - 640; AirFieldPatrolPath[5 ,0] = startPosition[0] + 9216; AirFieldPatrolPath[5 ,1] = startPosition[1] + 811; AirFieldPatrolPath[6 ,0] = startPosition[0] + 9984; AirFieldPatrolPath[6 ,1] = startPosition[1] + 2219; AirFieldPatrolPath[7 ,0] = startPosition[0] + 11306; AirFieldPatrolPath[7 ,1] = startPosition[1] + 3712; //XLs AirFieldPatrolPath end //------------------------------------------- // Setup the Patrol here... //XL gulagPatrolState Start gulagPatrolState[0] = PATROL_TYPE_LINEAR; gulagPatrolState[1] = 9; //?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] = startPosition[0] ; gulagPatrolPath[0 ,1] = startPosition[1] ; gulagPatrolPath[1 ,0] = startPosition[0] + 682.667; gulagPatrolPath[1 ,1] = startPosition[1] + 170.666; gulagPatrolPath[2 ,0] = startPosition[0] + 1963; gulagPatrolPath[2 ,1] = startPosition[1] + 127.333; gulagPatrolPath[3 ,0] = startPosition[0] + 2518; gulagPatrolPath[3 ,1] = startPosition[1] - 1536; gulagPatrolPath[4 ,0] = startPosition[0] + 3797.333; gulagPatrolPath[4 ,1] = startPosition[1] - 1536; gulagPatrolPath[5 ,0] = startPosition[0] + 4608; gulagPatrolPath[5 ,1] = startPosition[1] - 1663.997; gulagPatrolPath[6 ,0] = startPosition[0] + 5760; gulagPatrolPath[6 ,1] = startPosition[1] - 1664; gulagPatrolPath[7 ,0] = startPosition[0] + 5718; gulagPatrolPath[7 ,1] = startPosition[1] + 512; gulagPatrolPath[8 ,0] = startPosition[0] + 5248; gulagPatrolPath[8 ,1] = startPosition[1] + 810.666; 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) and (conTimer == -1) then conTimer = getTime + 30; endif; if (Not test_Covoy_go_1) and ((getTime > conTimer) and (conTimer > 0)) then conTimer = 0; test_Covoy_go_1 = true; trans toGulag; endif; //----------------------------------- // Trigger for Convoy to Move to the AirField if (Convoy_Go_2) and (conTimer2 == -1) then conTimer2 = getTime + 30; endif; if (Not test_Covoy_go_2) and ((getTime > conTimer2) and (conTimer2 > 0)) then conTimer2 = 0; test_Covoy_go_2 = true; trans toAirField; 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; 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. //****************************************************************************************