package ScoreDrive; uses String, INIFile, iShip, Sim, iFaction, iScriptedOrders, Task, Math, iFormation, iShipCreation, iComms, Object, State, iInventory, iAI, iPilotSetup, iUtilities, iConversation, Text, iLagrangePoint, Group, Object, iMissionTracker, iCutsceneUtilities, iHUD, iGame, iRemotePilot, iDirector, iLoadout, iGUI, Config, iMultiplay, Input, iRegion; provides Main, ScenarioMain; prototype Main(); prototype ScenarioMain(); prototype task MissionHandler (); prototype task MainTask (); ScenarioMain() { iGame.SetGameType( IGT_Mod ); iGame.StartNewGame( "map:/geog/badlands/hoffers_wake", "ScoreDrive" ); } // --------main-------- Main() { start MainTask(); // Start the mission handler task } task MainTask() { // call the mission handler task Task.Detach ( start MissionHandler () ); } // Create waypoints for rings hgroup setup_waypoints ( hsim location ) { hgroup waypoints = Group.Create(); hsim temp; float dist = 1000; int numOfRing; for ( numOfRing = 1; numOfRing <= 10; dist += 7000) { temp = iUtilities.CreateWaypointRelativeTo ( location, dist, 0, 0 ); iUtilities.RenameSim ( temp, String.Join("WayPoint ", String.FromInt ( numOfRing ))); Group.AddSim ( waypoints, temp ); ++numOfRing; } return waypoints; } // create rings hgroup create_rings ( hgroup waypoints ) { hsim ring; hgroup rings = Group.Create(); int number_of_waypoints = Group.SimCount ( waypoints ); int l; for ( l = 0; l< number_of_waypoints ; ++l ) { ring = Sim.Create ( "ini:/sims/ships/utility/training_ring", String.Join ( "Ring", String.FromInt ( l +1 ) ) ); Group.AddSim ( rings, ring); Sim.PlaceAt ( ring, Group.NthSim ( waypoints, l )); iSim.SetSensorVisibility ( iSim.Cast ( Group.NthSim (rings, l ) ),true ); Sim.SetOrientationEuler( ring, 90, 0, 0); } return rings; } // switch current target task switch_rings ( hgroup rings, int index ) { iSim.SetSensorVisibility ( iSim.Cast ( Group.NthSim ( rings, index ) ), true ); Task.Sleep ( Task.Current (), 0.0001 ); iHUD.SetTarget ( Group.NthSim ( rings, index ) ); iSim.SetSensorVisibility ( iSim.Cast ( Group.NthSim ( rings, index-1 ) ), false ); } //task MissionHandler () // // mission handler task to setup initial waypoints and launch/cleanup // necessary monitior tasks. task MissionHandler () { hship player_ship; hsim grounds_waypoint; hsim temp; hgroup waypoints, rings; int l; int templ; int current_waypoint = 0; //-----------create player ship and ground_point---------------------------- player_ship = iShip.Create( "ini:/sims/ships/player/fast_attack_prefitted", "Advanced Patcom" ); grounds_waypoint = iUtilities.CreateWaypointRelativeTo ( iMapEntity.FindByName ( "Lucrecia's Base" ), 24 km, 0, 0 ); iUtilities.RenameSim ( grounds_waypoint, "Grounds waypoint"); iSim.SetSensorVisibility ( iSim.Cast ( grounds_waypoint ), true); Sim.PlaceRelativeTo ( player_ship, grounds_waypoint, 0, 0, 0 ); Sim.SetOrientationEuler ( player_ship, 90, 0, 0 ); iShip.InstallPlayerPilot(player_ship); //----------- end ---------------------------- // Setup rings waypoints = setup_waypoints ( grounds_waypoint ); rings = create_rings ( waypoints ); iHUD.SetTarget ( iSim.Cast(Group.NthSim ( rings , 0) ) ); schedule { every 0.1 : { if ( Sim.DistanceBetween ( player_ship, Group.NthSim ( waypoints, current_waypoint ) ) < 250 && current_waypoint <= Group.SimCount ( waypoints ) ) { ++current_waypoint; start switch_rings ( rings, current_waypoint ); } } } }