Space Engineers

Space Engineers

AI Enemies - Waves of NPCs
 This topic has been pinned, so it's probably important
DarkkShadow0  [developer] 11 May, 2015 @ 6:35pm
Custom Ships (Have the AI control your creations)
Basics
This may seem a little complicated at first, but it's really quiet simple. I considered several ways to implement this functionality, and finally decided that this way was going to be the easiest to use.

First paste the ships you want to use as AI ships into a world where the mod is used. Remember that you really should not use this mod in any worlds you really care about, as though it can occasionally be unstable and I don't want you to lose your work due to some bug I overlooked.

Then check your ship's name. It is usually something like "Small Ship 1844". You can leave the names as their defaults, but I recommend changing the names to something more descriptive. Make note of the name, as though you will need it in the next step.

Use the command "ai custom save". This will show you a list of all the ships in the current world. Find your ship on that list. It's entry may look something like this: "6: Small Ship 1844".

The first number is what you are looking for. In my case this number is 6. To save this ship into the mod's memory, use this command: "ai custom save 6". Remember to use the number you got, instead of the 6.

Your ship is now saved in the mod's memory. You can see all the ships you have by using the command: "ai custom list". This command will show you all the ships you have saved in the mod's memory. You will notice how the ship now has a different number. This is normal. The number represents the ship's index in the list, and this is a different list. When I used this command my ship showed as "1. Small Ship 1844.xml". We will call this number (the '1') the ship's ID.

Now to spawn the ship you simply use: "ai custom spawn 1". Remember to replace the '1' with the new number you got from "ai custom list".

I know this seems like a lot of commands to remember, which is why you can access a list of these commands at any time by using the command "ai custom". It contains brief descriptions of these commands, so you can easily look them up.

Read on to find out how to execute these commands more efficiently and how to spawn multiple custom ships with only a single command.

Advanced
I know that when playing games I hate typing in long commands. So I made shorthand aliases. What this means is that "custom" can be used as "c" and "spawn" can be used as "s".

These commands are valid and will work:
  • ai c list
  • ai c spawn 1
  • ai c s 1
  • ai custom s 1

Additionally the syntax of the spawn command can be used in a more advanced fashion. You can spawn multiple ships in one command by separating the IDs with spaces:
  • ai custom spawn 1 2 3 (spawn one of each ids: 1, 2 ,3)
  • ai custom spawn 1 2 2 (spawn one ship with id 1, spawn two ships of id 2)
  • ai c s 1 2 3
Or if you're looking to do things even faster you can spawn ships in bulk. Instead of specifying an id, you specify an id and a number. The syntax of the command is similar: "ai custom spawn id:number". Use a ':' to separate the values. Examples:
  • ai custom spawn 1:3 2:4 (spawn 3 copies of ship id 1 and 4 copies of ship id 2) (total of 7 ships spawned)
  • ai c s 1:4 4:2 (spawn 4 copies of ship id 1 and 2 copies of ship id 4) (total 6 ships spawned)
  • ai c s 1:1 1 1:0 (spawn 1 copy of ship id 1, spawn another copy of ship id 1, and spawn no copies of ship id 1 (obviously this can be done better and more easily, but it works)) (total 2 ships spawned)

Bugs
If you experience issues with custom ships; keep in mind:
  • Often times crashes or other problems can be a result of other mods. If your ship uses any blocks from a different mod; it is possible that the AI will have difficulties controlling it. If that is the case; let me know, and I will look into fixing it (although some inter-mod interactions may simply not be possible.)
  • Custom ships need to have at least one cockpit or remote control block. Such a block provides the interface for this mod to control the ship. If you attempt to spawn an AI ship without one of these control blocks, you may get an error or lack of movement.
  • If you attempt to spawn a ship which has blocks from another mod; and that mod is not loaded in the current mission; expect errors or worst.

Thoughts?
I hope I made this simple enough for everyone to understand, and yet advanced enough to allow efficient use. Let me know if something is not clear or if you can think of a simpler/more comprehensible syntax.

Keep in mind that it is very easy to order the game to spawn a LOT of ships, but if you spawn too many expect lag or a crash.

Disclaimer
Do not use this mod as a safe way to store/backup your ships. The mod can occasionally make a mistake and delete some of the ships from its internal storage. For example if you attempt to spawn a ship which requires elements of a mod which is not loaded, this script will see the file as corrupt and remove it.
Last edited by DarkkShadow0; 11 Mar, 2016 @ 5:38am
< >
Showing 1-9 of 9 comments
Hunter 27 Aug, 2015 @ 4:23pm 
Thanks for adding the ability for custom ships! Really cool! :)
Red Eclipse 18 Nov, 2015 @ 4:22am 
This is really awesome. You didn't explain how to spawn friendly vs enemy ships though. Or did you?
DarkkShadow0  [developer] 18 Nov, 2015 @ 8:31am 
Not in this post sorry. Choosing spawn type is a general feature applicable to different types of spawns too.
To spawn an allied ship use: /ai setpilot ally
All ships spawned from then on will be allied.
To revert back to spawning hostile ships: /ai setpilot adv OR /ai setpilot basic
Aschran 15 Mar, 2016 @ 3:19pm 
Hello im tryng your mod because it look amazing for making personal fleets.
But i appear to simply cant spawn an ai custom ship on my server.
i mean the commands work correctly but my drone is already off when it appear.
I don't really know is cause of this, because my ship before i save it on the drone list, seem to be correctly made with its batteries on by default.
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=646094008

i wil ltry again ..
ZUGA 2 Jun, 2016 @ 7:08am 
This may seem a little complicated at first, but it's really quiet simple. take a look and guess whats wrong.
Ezo21 3 Oct, 2016 @ 11:01am 
Where are these ships when I spawned them? I can't find them anywhere.
DarkkShadow0  [developer] 5 Oct, 2016 @ 4:13am 
The ships should spawn where-ever the spawn location is set (default: 1000,1000,1000) . If you are trying to spawn ships within the atmospehere of planets, it probbaly won't work.
Ezo21 5 Oct, 2016 @ 2:35pm 
Thanks for help :)
Syrett 15 Feb, 2018 @ 6:10pm 
um how would i use commands im having trouble.
< >
Showing 1-9 of 9 comments
Per page: 1530 50