Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Main(string argument)
- {
- string group_name = "[Le Meow] frontal_turrets"; //name of group containing only needed turrets, rename if you want
- var group = GridTerminalSystem.GetBlockGroupWithName(group_name);
- var turrets = new List<IMyTerminalBlock>();
- string type;
- bool enableIdle = false; //change to false if you don't need idle movement
- bool enableAutoshoot = true; //change to false if you don't need autoshoot
- if (group == null)
- {
- Echo("Turrets not found");
- return;
- }
- Echo("Group found: " + group.Name);
- group.GetBlocks(turrets);
- for (var i = 0; i < turrets.Count; ++i)
- {
- type = turrets[i].GetType().Name;
- if (type == "MyLargeGatlingTurret" || type == "MyLargeInteriorTurret" || type == "MyLargeMissileTurret")
- Echo(i + 1 + ") " + turrets[i].CustomName);
- else
- {
- Echo(turrets[i].CustomName + " is not a turret. Stopping.");
- return;
- }
- }
- if (turrets[0].GetValueBool("TargetLargeShips") == true)
- { //to detect if turrets work as usual (i doubt somebody turns it off for any reason)
- Echo("Frontal turrets mod enabled.");
- foreach (IMyTerminalBlock turret in turrets)
- {
- turret.ApplyAction("EnableIdleMovement_Off");
- turret.ApplyAction("TargetMeteors_Off");
- turret.ApplyAction("TargetMissiles_Off");
- turret.ApplyAction("TargetSmallShips_Off");
- turret.ApplyAction("TargetLargeShips_Off");
- turret.ApplyAction("TargetCharacters_Off");
- turret.ApplyAction("TargetStations_Off");
- turret.ApplyAction("TargetNeutrals_Off");
- var kek = turret as IMyLargeTurretBase; //it has to be so
- kek.Azimuth = 0f;
- kek.Elevation = 0f;
- kek.SyncElevation();
- kek.SyncAzimuth();
- if (enableAutoshoot) turret.ApplyAction("Shoot_On");
- }
- }
- else
- {
- Echo("Frontal turrets mod disabled.");
- foreach (IMyTerminalBlock turret in turrets)
- {
- if (enableAutoshoot) turret.ApplyAction("Shoot_Off");
- var kek = turret as IMyLargeTurretBase;
- kek.Azimuth = 0f;
- kek.Elevation = 0f;
- kek.SyncElevation();
- kek.SyncAzimuth();
- kek.ResetTargetingToDefault(); //turn on AI aiming, for some reason
- if (enableIdle) turret.ApplyAction("EnableIdleMovement_On");
- if (turret.GetType().Name != "MyLargeMissileTurret") turret.ApplyAction("TargetMeteors_On");
- if (turret.GetType().Name == "MyLargeInteriorTurret") turret.ApplyAction("TargetMissiles_On");
- turret.ApplyAction("TargetSmallShips_On");
- turret.ApplyAction("TargetLargeShips_On");
- if (turret.GetType().Name != "MyLargeMissileTurret") turret.ApplyAction("TargetCharacters_On"); //who shoots characters with rockets?
- turret.ApplyAction("TargetStations_On");
- turret.ApplyAction("TargetNeutrals_On");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement