> For the complete documentation index, see [llms.txt](https://fehdead.gitbook.io/npc-kit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fehdead.gitbook.io/npc-kit/api/limits.md).

# Limits

**What NPC Kit can't do, and the numbers to stay under.**

### Per map

{% hint style="danger" %}
**Keep a map under 64 modelled actors**: its own, the party's and the NPCs'. The game crashes past 64, with no warning.
{% endhint %}

Map 289 alone takes 31 and map 290 takes 29, with a party of three; the fullest map measured, 640, takes 44. Each kit NPC takes one, and a mount, summon or guest takes more later. To read a map's count, stand on it with no kit NPC and read `memory.readU32(0x022C70A4)`.

**At most 40 NPCs per map**, all scripts together. Past that the log says so and the oldest are dropped.

**A `motionFrom` adds a hidden NPC** to its map, one per model and motion set in a script: it takes one of the 40 and one of the 64. At most 256 NPCs with `motionFrom`, all maps and scripts together; past that the NPC fails with `NPC Kit holds 256 of them at most`.

***

### The script

| limit                                                                             | why                                                                                                                                                                                                                                                        |
| --------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| no `if`, `while` or script variable in the recorded script                        | a recorded script has no variables. Branches, loops and state are your Lua, in [`npc.lua`](https://fehdead.gitbook.io/npc-kit/api/lua-during-the-game.md)                                                                                                  |
| calls with an `Int (Offset)` argument, such as `getpos`, are left out             | that argument names a script variable                                                                                                                                                                                                                      |
| 44 calls are left out                                                             | they freeze the game, take a script variable, have no handler, share the kit's own handler, touch the player's saves, or reset the game to a new one                                                                                                       |
| a call whose first argument is an actor needs a real one                          | `getmp_1f5(1)` freezes the game when 1 is no actor                                                                                                                                                                                                         |
| at most 1023 integers outside -32768..32767 and 4095 floats, all scripts together | the script image keeps them in two pools, one entry per different value in a script; each `npc.on` / `npc.actor` target takes an integer. Past that the NPC fails with `the image's value pool is full`                                                    |
| about 232 KB for every NPC's script, name and cameras, all scripts together       | the script image's room. Past that the NPC fails with `no room left for more NPCs`                                                                                                                                                                         |
| the full-screen menu calls show little in the field                               | most show nothing; `fs_stonewinopen` and `fs_foodwinopen` show a counter until their `close`, `fsttl_opencommand` the title's command list until `fsttl_closecommand`, `fsttl_openconfig` the title's Config window, which only the player's Cancel closes |

***

### Loading

| limit                                                                                         | why                                                                                                                            |
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `npc.add` takes effect the next time the map loads                                            | a running map's script is never rewritten                                                                                      |
| a declaration made before NPC Kit installed fails in the log, with its `id`, not at `npc.add` | script load order is arbitrary; the other declarations still go through. Declare your NPCs on `onInitDone`, as the examples do |
| if the kit's talk hook fails, `npc.add` raises an error                                       | a talk would never end                                                                                                         |

***

### Text

| limit                                                              | why                                                                        |
| ------------------------------------------------------------------ | -------------------------------------------------------------------------- |
| `name` is at most 31 bytes in the game's encoding                  | the name tag copies it with no limit, and more ends the game with no error |
| `name` and dialog text go through the game's encoding              | a character the game lacks fails with the Lua Loader's message             |
| a Latin name is wrong with the game in Japanese, Korean or Chinese | the Lua Loader refuses Korean and Chinese outright                         |

***

### Scenes

During a scene the NPCs are hidden, and their scripts and `npc.lua` keep running. A dialog opened from `npc.lua` in `main` would open over the scene.
