Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. public void Main(string argument)
  2. {
  3. string group_name = "[Le Meow] frontal_turrets"; //name of group containing only needed turrets, rename if you want
  4. var group = GridTerminalSystem.GetBlockGroupWithName(group_name);
  5. var turrets = new List<IMyTerminalBlock>();
  6. string type;
  7. bool enableIdle = false; //change to false if you don't need idle movement
  8. bool enableAutoshoot = true; //change to false if you don't need autoshoot
  9.  
  10. if (group == null)
  11. {
  12. Echo("Turrets not found");
  13. return;
  14. }
  15. Echo("Group found: " + group.Name);
  16. group.GetBlocks(turrets);
  17. for (var i = 0; i < turrets.Count; ++i)
  18. {
  19. type = turrets[i].GetType().Name;
  20. if (type == "MyLargeGatlingTurret" || type == "MyLargeInteriorTurret" || type == "MyLargeMissileTurret")
  21. Echo(i + 1 + ") " + turrets[i].CustomName);
  22. else
  23. {
  24. Echo(turrets[i].CustomName + " is not a turret. Stopping.");
  25. return;
  26. }
  27. }
  28.  
  29. if (turrets[0].GetValueBool("TargetLargeShips") == true)
  30. { //to detect if turrets work as usual (i doubt somebody turns it off for any reason)
  31. Echo("Frontal turrets mod enabled.");
  32. foreach (IMyTerminalBlock turret in turrets)
  33. {
  34. turret.ApplyAction("EnableIdleMovement_Off");
  35. turret.ApplyAction("TargetMeteors_Off");
  36. turret.ApplyAction("TargetMissiles_Off");
  37. turret.ApplyAction("TargetSmallShips_Off");
  38. turret.ApplyAction("TargetLargeShips_Off");
  39. turret.ApplyAction("TargetCharacters_Off");
  40. turret.ApplyAction("TargetStations_Off");
  41. turret.ApplyAction("TargetNeutrals_Off");
  42. var kek = turret as IMyLargeTurretBase; //it has to be so
  43. kek.Azimuth = 0f;
  44. kek.Elevation = 0f;
  45. kek.SyncElevation();
  46. kek.SyncAzimuth();
  47. if (enableAutoshoot) turret.ApplyAction("Shoot_On");
  48. }
  49. }
  50. else
  51. {
  52. Echo("Frontal turrets mod disabled.");
  53. foreach (IMyTerminalBlock turret in turrets)
  54. {
  55. if (enableAutoshoot) turret.ApplyAction("Shoot_Off");
  56.  
  57. var kek = turret as IMyLargeTurretBase;
  58. kek.Azimuth = 0f;
  59. kek.Elevation = 0f;
  60. kek.SyncElevation();
  61. kek.SyncAzimuth();
  62. kek.ResetTargetingToDefault(); //turn on AI aiming, for some reason
  63.  
  64. if (enableIdle) turret.ApplyAction("EnableIdleMovement_On");
  65. if (turret.GetType().Name != "MyLargeMissileTurret") turret.ApplyAction("TargetMeteors_On");
  66. if (turret.GetType().Name == "MyLargeInteriorTurret") turret.ApplyAction("TargetMissiles_On");
  67. turret.ApplyAction("TargetSmallShips_On");
  68. turret.ApplyAction("TargetLargeShips_On");
  69. if (turret.GetType().Name != "MyLargeMissileTurret") turret.ApplyAction("TargetCharacters_On"); //who shoots characters with rockets?
  70. turret.ApplyAction("TargetStations_On");
  71. turret.ApplyAction("TargetNeutrals_On");
  72. }
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement