/// <summary> /// Sends commands to the autopilot. /// </summary> /// <param name="content">The commands for the autopilot.</param> void SendMessageToAutopilot(string content) { Echo("AP: " + content); parameters[2] = TerminalActionParameter.Get(content); ITerminalAction action = Me.GetActionWithName("SendMessage"); if (action == null) { Echo("ARMS is not loaded. ARMS is a prerequisite for this script."); } else { Me.ApplyAction("SendMessage", parameters); } }
/// <summary> /// Sends a message to one or more blocks. All matching Programmable blocks and Autopilot blocks /// will be sent a message. /// </summary> /// <param name="targetGrid">Every grid with targetGrid in the name will receive a message</param> /// <param name="targetBlock">Every Programmable Block or Autopilot block with targetBlock in /// the name will receive a message</param> /// <param name="content">The content of the message</param> void SendMessage(string targetGrid, string targetBlock, string content) { arguments.Clear(); arguments.Add(TerminalActionParameter.Get(targetGrid)); arguments.Add(TerminalActionParameter.Get(targetBlock)); arguments.Add(TerminalActionParameter.Get(content)); ITerminalAction action = Me.GetActionWithName("SendMessage"); if (action == null) { Echo("ARMS is not loaded. ARMS is a prerequisite for this script."); } else { Me.ApplyAction("SendMessage", arguments); } }
public void Main(string argument, UpdateType updateSource) { if (updateSource == UpdateType.Update10) { enemyUpdated = false; //_program.Echo($"CQ: {camIndex}"); if (cameras[camIndex].CanScan(RANGE)) { var info = cameras[camIndex].Raycast(RANGE, PITCH, YAW); if (!info.IsEmpty()) { if (info.Relationship == MyRelationsBetweenPlayerAndBlock.Enemies) { enemyUpdated = true; } lastDetected = info; SetDisplayColor(); var sbdisplay = new StringBuilder(); sbdisplay.AppendLine(); sbdisplay.AppendLine($"Time: {DateTime.Now.ToString()}"); sbdisplay.AppendLine($"Distance: {(Vector3D.Distance(cameras[camIndex].GetPosition(), lastDetected.HitPosition.Value)):0.00}m"); sbdisplay.AppendLine($"Name: {lastDetected.Name}"); sbdisplay.Append($"Type: {lastDetected.Type} "); sbdisplay.AppendLine($"Speed: {lastDetected.Velocity.Length().ToString("0.0")}m/s"); sbdisplay.AppendLine($"GPS:{lastDetected.Name}:{lastDetected.Position.X.ToString("0.00")}:{lastDetected.Position.Y.ToString("0.00")}:{lastDetected.Position.Z.ToString("0.00")}:"); InfoDisplay.WriteText(sbdisplay.ToString()); } } else { Runtime.UpdateFrequency = UpdateFrequency.None; } camIndex++; if (camIndex >= cameras.Count) { camIndex = 0; PITCH = 0; YAW = 0; } else { PITCH = RandomizePitchYaw(raycastConeLimit); YAW = RandomizePitchYaw(raycastConeLimit); } if (autoShoot && enemyUpdated) { Echo("shoot"); Runtime.UpdateFrequency = UpdateFrequency.None; for (int i = 0; i < maxTurretsPerCycle; i++) { turrets[turretIndex].ApplyAction(Actions.SHOOT_ONCE); turretIndex++; if (turretIndex >= turrets.Count) { turretIndex = 0; } } // _program.Echo("Shoot"); } if (!lastDetected.IsEmpty() && enemyUpdated) { TargetTurrets(); } } else if (argument.ToLower().Contains("setrange")) { RANGE = Convert.ToDouble(argument.Split(':')[1].Trim()); } else if (argument.ToLower().Contains("stop")) { Echo("UnAim"); foreach (var turret in turrets) { turret.ResetTargetingToDefault(); Me.ApplyAction(Actions.TURN_OFF); } } var sb = new StringBuilder(); sb.AppendLine($"LRT: {Runtime.LastRunTimeMs}"); sb.AppendLine($"IC: {Runtime.CurrentInstructionCount}"); sb.AppendLine($"CCD: {Runtime.CurrentCallChainDepth}"); Echo(sb.ToString()); if (Runtime.LastRunTimeMs > 2) { Runtime.UpdateFrequency = UpdateFrequency.Update100; } else { Runtime.UpdateFrequency = UpdateFrequency.Update10; } }