> 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/what-vanilla-does.md).

# What Vanilla Does

**What vanilla NPCs do, to copy, and the calls that trap the player.**

### Placing and moving

* **Start every NPC the way vanilla does**: the `init` of the [Starting Template](https://fehdead.gitbook.io/npc-kit/api/starting-template.md) (and `placeNpc` in the examples) is the setup most vanilla NPCs share, collision and weight included. Without `usecharhit`, `setweight(-1)` and `set_ignore_hitgroup` the player pushes the NPC around.
* **`setautorelax(1)`**: the game gives it to its own NPCs only. Without it a motion stops on its last frame.
* **A model key is absolute**: `0x00630000` is Vaan's `c0000`. The file-relative `0x03000000` holds `init` for good, which stops every talk of the map.
* **`stdmotionread`** with a motion set the model lacks is a silent T-pose.
* **Height**: a standing NPC with `usemapid(0)` stays at the `y` it was given; `usemapid(1)`, then `setpos2` and `fetchambient()`, take the ground's height. A point off the walkmesh under `usemapid(1)` leaves the NPC at the map's origin.
* **Sitting**: a motion set can hold more than one posture. Vanilla sits its NPCs with `stdmotionread(18)`, `stdmotionreadsync()`, `stdmotionvariation(1)` or `(2)`, then the idle `stdmotionplay_2c2(0x01000000, 0)`. On a chair or a ledge it adds `usemapid(0)` with the seat's `y`, and lights the NPC with `fetchambient_4e1` at a point 0.5 to 2 units in front of it, on the floor.
* **Blocking**: `set_ignore_hitgroup(1)` blocks the leader, `(10)` lets the leader through. An NPC that blocks must stay out of a vanilla walker's route.
* **Walking**: `move` has no limit, so in a talk it holds the player if the walk is blocked. `rmove`, `wait` and `movecancel` walk with a limit.
* **`movea_60`, `cmovea_5c`, `amovea_4d5`** take `(actor, speed)` and `amove_4d3` takes `(x, y, z, speed)`. At speed `0.0` the NPC doesn't walk and the call never returns. Actor `-1` is the party leader.
* **`ridechocobo`** needs `partyallread` right after it. Alone, it sets the mode with no mount and the leader can't move.
* **Crystals**: an NPC with a `talk` in front of a crystal takes the button from the crystal. Place it off the crystal's front.
* **Foes** walk as close as about 1.3 units from an NPC's centre.
* **Summons**: a summon's cinematic doesn't hide the NPCs; the kit hides them only for a scene.

***

### Around a talk

Every vanilla talk opens and closes the same way. Copy `talkOpen`, `talkClose` and `talkTerm` from the [Starting Template](https://fehdead.gitbook.io/npc-kit/api/starting-template.md): they turn the NPC to the player, play its talking pose, move its mouth (`setkutipakustatus`) and nod its head (`setunazukistatus`) while it speaks, and put the HUD, the player's control and the idle back after.

***

### Calls that wait

A call that waits holds the script until its condition holds. In `talk` that holds the player.

{% hint style="danger" %}
**These never return from an NPC on a field map:** `debug_eventsync`; `spattackreadsync` and `spattacksync` with `0` or with no Quickening in the session; `debug_bind*(0)`; `stdmotioneventsync` with a motion that has no event; `effecttotalsignalsync` and `motiontotalsignalsync` with nothing that raises their bit.
{% endhint %}

* **`seteventwakerect(1)` freezes the game**: it needs a touch handler, which a kit NPC doesn't have. `seteventwakerect(0)` is safe.
* **`tutorial_sync_partymenu`** and **`openfullscreenmenu_48d`** return when the full-screen menu next closes, the main menu opened by the player included.
* **`keywait`** takes the pad's keymask: bit `n` is keymap slot `n`. `keywait` waits for held, `keywaitr` for repeat, `keywaitt` for the press, `keywaittr` for the release.
* **`debug_mesask`** opens a window that ignores the buttons and takes the player's control until it is closed.

***

### Good to know

* **`additemmes`** gives the item, it doesn't only show the notice.
* **A talk doesn't suspend a fight.** Vanilla does it only away from towns and only in 27 talks; `npc.suspendbattle()` and `npc.resumebattle()` add it.
