Space Engineers

Space Engineers

Not enough ratings
Setting up Swarm
By Xardkort
  • Drone control.
  • Uranium/ammunition resupply.
  • Ordering drones in Core for autoprinting.
  • Smart combat AI.
  • Projectile/obstacle avoidance.
  • Enemy detection via projectile trajectory/when taking damage.
  • Protection from friendly fire.
  • Graphical interface.
  • Data transmission to Core, Swarm, and Launcher.
  • Data reception from Core and Swarm.
   
Award
Favorite
Favorited
Unfavorite
Important
  • It is not recommended to use course missile launchers because the projectile acceleration is not taken into account when calculating their lead (I removed this function because I ran out of space for the code. In any case, they are useless in PVP due to the low initial speed of the missile)
  • If you play on a Torch server with concealment and drones are affected by it, control over them will be lost
  • Do not leave the sensor area when compiling/running with an argument
  • Do not use cockpits/seats while compiling
  • Do not place anything in the custom data of programmable blocks
  • Group names are not case sensitive and can be supplemented with prefixes and suffixes
  • If there is an enemy player in the sensor's area, the interface will be blocked
  • If the enemy starts hacking the programmable block, self-destruction will start
Setting
If something goes wrong, the script will report it in Echo/on the PB screen/in the error list in the interface.
Swarm:
  1. Create a group with the tag Swarm and any unique id in the name (for example: Swarm 1).
  2. Add the following blocks to it:
    • programmable block
    • LCD panel (interface will be displayed on the PB screen if the LCD is missing/destroyed in battle)
  3. Add to Core group:
    • RC/cockpit blocks
    • sensor
    • connectors
    • containers (for ammunition/uranium)
    Optional:
    • welders (for auto repair, launched with Goto/Home/Dock command if drone radius < 6 and its connector is damaged, 1 welder = 1 repair point)
    • grinders (for auto grinding (video), 1 grinder = 1 grinding point, add only the central grinder, grinders around it will be added automatically)
  4. Paste the script into a programmable block added to the Swarm group and click "recompile".
Drone:
Required blocks:
  • thrusters in all directions of movement
  • gyroscopes
  • batteries/reactors
  • turrets (to search for enemies and their projectiles (shells are seen by all turrets except the artillery one))
  • cameras (for target lock and path scanning)
  • RC block/cockpit (sets the orientation of the drone, destroying this block = death of the drone)
  • connector
Optional blocks:
  • course guns (without them the drone will work according to a simplified algorithm, which will greatly reduce the script execution time)
  • antenna
  • containers (for ammunition)
  • AI defensive/offensive block (to increase the aiming radius of turrets to their maximum firing range)
  • projector (for auto repair)
  • warheads (for self-destruction on command or when the drone is hacked)
To autoprint: create a blueprint and load it into the printer, then order it in Swarm under Setup/Order (remote control block upward direction = takeoff direction).
To add manually: prefix all blocks with DN + any number + name (for example: DN1 Scout (Whip's Block Renamer is recommended)) and dock the drone to a grid that has a Swarm script.
If you play on servers, to reduce the script execution time it is recommended to use as few gyroscopes and thrusters as possible, 1 gyroscope = 1 grid, 1 thruster = 1 direction of movement (the script does not care about the number of blocks, it controls all gyroscopes as one, the same with thrusters (each direction of movement is considered one thruster), so the delay in execution time does not occur on the script side).
Arguments
Argument
Description
w, s, a, d or up, down, left, right
menu navigation
def
protect last selected grid in GoTo/Defense list (default is grid with script)
dock
start docking
gps
find all gps in argument for GoTo/Gps list
set
set number of drones (for example: set8 or set 8)
tag
set tag for data exchange via antennas
Fire modes
Selected automatically.
Rapid – for gatlings/autocannons/rockets.
Turrets only – for drones without course weapons, works according to a simplified algorithm, greatly reducing the load on the script.
Salvo – artillery/railguns (alternate firing with a delay).
Volley – fire volleys from artillery/railguns and while reloading, fire from gatlings/autocannons/rockets.
Attack radius
Selected automatically.
The attack radius may be reduced if the target is actively maneuvering.
A smaller radius is always a priority (if using missiles and railguns, the radius will be 550 m).
Missile turrets only – 500.
Missile guns – 550.
Small autocannon/gatling turrets only – 590.
Small autocannon/gatling guns – 650.
Large gatling turrets – 700.
Assault guns/turrets – 1000 or 1150 if you have a weapon with a larger attack radius.
Small railguns – 1200.
Artillery guns/turrets – 1300.
Large railguns – 1400,
Distribution by connectors
It happens automatically.
The screenshot shows how free space is distributed between connectors.
Only connector blocks are taken into account when calculating free space.
You can prevent drones from using certain connectors. For example, your drone's name is shown in the "Info" section as "scout 42", add "scout" to the connector's custom data, now all drones named "scout" will ignore this connector (case sensitive). You can add multiple names, each new name must start on a new line. The custom data is checked by the script before sending drones to the dock, so any changes made after the drone has selected the connector will be ignored.
Interface
Errors list
If something doesn't work or you see a red square in the upper left corner. Select the topmost interface element and quickly double-click up (w). If the script has detected problems, a list of errors/warnings will open.
Info – information about drones
< remcon – the drone will stop performing its current task and enable its antenna so you can connect to its RC block.
remove > – remove the drone, instant removal if it is docked, if not, the docking procedure will begin and after its completion the drone will be removed, if the drone is damaged so much that it is impossible to dock, and it has warheads, it will self-destruct.
Assault 10 – drone name.
Reloading – current drone state, Loading - initialization, Recharging - charges batteries/fills reactors, Reloading (ammunition), Idle, Undocking, TakeOff, Defence - protection of the selected grid, Attack - flies to the enemy, Dogfight, Seek - looking for an enemy, GoDock - flies to dock, GoRepair - flies for repairs, GoGrinder - flies to the grinder for auto grinding, Repairing, RC - remote control, Wait, Removing.
No ammo – additional information, No ammo - no ammunition in Core containers, No uran - no uranium in Core containers, Damaged - the drone has received critical damage (gyros are destroyed, all engines in one direction or the connector is destroyed, independent docking in this state is impossible), Low ammo - running out of ammo (If not docked, docking with the nearest grid will be initiated), Low energy - low charge/uranium (docking with the nearest grid will be initiated), No conveyor - there is no conveyor to the resource containers, No volume - there is no free space in the drone's inventory, No reactors - all reactors are damaged/destroyed, No welder, No grinder.
GoTo/Pos – move to position
Move to the position:
Raycast – target locked by lidar and its pursuit, if there is no target, defend the last grid selected in the Defense section.
My grid – script grid center.
Swarm – swarm center.










GoTo/Beam – beam riding
Beam will be directed forward (in the orientation of the RC block/cockpit) from the center of your grid.
Ride – follow the beam.
Length – beam length.
Update – update the beam.










GoTo/Defence – defend the grid
Drones will protect the grid selected in the list and follow it.
GoTo/Home
Dock – will start the docking process, if you have no free connectors left on the grid, the remaining drones will dock to allied grids (damaged drones will ignore the command. If there are welders in the Core group, then drones with damaged connectors and a radius of < 6 will first fly to them, and in case of successful repair will begin docking).
Grinder – if there are grinders in the Core group, drones will fly to them for auto grinding.






Setup/Count – drone quantity management
Change count – quick way to increase/decrease the number of drones. When increasing, drones will be taken from the beginning of the list below, if the drones in the list end, the "Removing" commands to return to the dock for removal will be canceled. When decreasing, it will immediately delete docked drones (those to be deleted will be highlighted with a red rectangle in the Info section), upon arrival at the dock, it will delete: those already flying to it as needed (low ammo/energy, after repair), those received from the printer after printing, those free (not in combat/not searching for targets), all that remain (except damaged and remotely controlled (RC)).
Assault 10 – the name of the drone in the list from which you can select and add drones.
Setup/Refill – refill of ammunition/uranium
Fight time (m) – time of continuous shooting from turrets/course guns (affects the amount of ammunition).
Flight time (m) – time of continuous use of half of the drone engines (affects the amount of uranium/charging time).
Refilled – refill status, Loading – drones are still being initialized, Recharging – charging/resuppling uranium, Reloading – resuppling ammunition.
Uran – list of uranium/ammunition, select the first item to see the full list.
Coefficients are applied to the ammunition of some weapons as they start firing at targets earlier due to their larger firing range: assault cannon and small railgun = 1.3, artillery = 1.5, railgun = 2.
Setup/Broadcast – data exchange via antennas
Obstacle position data only.
Transceiver – receive/transmit data.
Radius – antenna range (do not set small values ​​as antennas search for each other once every 10 seconds).
Tag – tag (password) for secure data exchange.
Receivers – number of receivers receiving your data.
Transmitters – number of transmitters sending data to you.







Setup/Order – orders for printing
Anything you order in this section will fly off the printer after printing and dock to the grid where the Swarm is located (gravity engine is not supported, no space for code). You must be on the same grid as the Core to pick up/place an order.
Assault/Fighter и т.д. – list of blueprints available for printing in Core.








Setup/General – general settings
Min antenna radius – the radius beyond which the antennas are enabled.
Max antenna radius – the radius beyond which the antennas are disabled.
If Min = Max then the antennas will be disabled. Min/Max antenna broadcast radius are measured from the center of the last grid selected in "Defense" (by default - the grid with the script). Useful to avoid losing lagging drones, especially for "Torch" servers using concealment (it makes the grid inactive if it is at a certain distance from the players, often 5-6 km. Note that the script will not be able to restore full control over such a grid).
Flight dist – the distance beyond which the drone is prohibited from flying away from the destination.
Speed limit – speed limit in the world.
Scan grid – grids scanning, runs on all PBs that are connected to this PB, searches for drones, deletes destroyed/searches new blocks, Swarm/Core/Launcher scripts. Doesn't add new functionality (for example, if you add grinders to the grid, Scan grid won't add the "Grinder" command, you need to recompile the script).