> For the complete documentation index, see [llms.txt](https://docs.settlers-united.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.settlers-united.com/s4-lua-api-de/library-functions/ai/ai.newsquad.md).

# AI.NewSquad

## `AI.NewSquad(Partei, Befehl, X, Y)`

Erteilt allen Einheiten, die per Script erstellt wurden und noch keinen Befehl erhalten haben, einen Befehl. Jede Einheit kann nur einmal angesprochen werden. Mögliche Befehle sind:

|                           |                                                               |
| ------------------------- | ------------------------------------------------------------- |
| AI.CMD\_MOVE\_AND\_STAY   | Einheit bleibt am Zielort                                     |
| AI.CMD\_MOVE\_AND\_VANISH | Einheit verschwindet am Zielort                               |
| AI.CMD\_MOVE\_HOME        | Einheit bewegt sich zur Siedlung, erfordert keine Koordinaten |
| AI.CMD\_SUICIDE\_MISSION  | Einheit greift an, erfordert keine Koordinaten                |

Einheiten reagieren nur auf Befehle, wenn bei ihrer Erstellung der Parameter "zum Squad hinzufügen" auf 1 gestellt ist, z.B. bei Schiffen Sonst kann es passieren, dass die Einheiten erscheinen, aber nichts tun.

#### Rückgabewert

none

#### Beispiel

```lua
--gesamtes Beispiel
Vehicles.AddVehicle(100,200,2,Vehicles.FERRY,0,0,1) -- schiff wird durch NewSquad Befehl bewegt
Vehicles.AddVehicle(140,200,2,Vehicles.FERRY,0,0,0) -- schiff wird nicht bewegt (letzter parameter = 0)
AI.NewSquad(2, AI.CMD_MOVE_AND_STAY, 144, 340) -- das schiff auf X100 Y200 bewegt sich nun auf X144 Y340 zu


--mögliche implementierungen:
AI.NewSquad(2, AI.CMD_SUICIDE_MISSION )
AI.NewSquad(2, AI.CMD_MOVE_AND_STAY, 144, 340)
AI.NewSquad(2, AI.CMD_MOVE_HOME)
AI.NewSquad(2, AI.CMD_MOVE_AND_VANISH, 884, 11)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.settlers-united.com/s4-lua-api-de/library-functions/ai/ai.newsquad.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
