> 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/vm-reference/calls/bindp2_d4.md).

# npc.bindp2\_d4

```lua
npc.bindp2_d4(model, variation, colour)
```

|                         |                                                   |
| ----------------------- | ------------------------------------------------- |
| id                      | `0x00D4`                                          |
| arguments               | 3: Int, Int, Int                                  |
| in NPC Kit              | yes                                               |
| measured from a kit NPC | waits: holds the script until its condition holds |
| vanilla scripts         | 9877 calls in 288 of 1114 scripts                 |

## What it does

Gives the NPC its model, and holds the script until the model has loaded. Every NPC's `init` starts with it (after `setautorelax` and `usecharhit(0)`).

## Arguments

### `model` (Int)

Which model. **In NPC Kit it is the absolute key**, the `Identifier (Hex)` of `data/model-*.csv`: `0x006E0019` is the Seeq Merchant, `0x00630000` Vaan, `0x006D0001` a Wolf.

The vanilla scripts write `0x03000000 + n` instead, an entry of the map script's own model list (every vanilla call does). A kit NPC has no such list.

### `variation` (Int)

The model's variation: which version of its mesh is built. A model's valid values are in its `Variation` cell in `data/model-*.csv` when filled. Vanilla's most common pairs with `colour`: `(1, 0)`, `(0, 0)`, `(2, 1)`. `bindp2(m)` is `bindp2_d4(m, 1, 0)`.

### `colour` (Int)

The colour variation: which set of textures. Valid values in the model's `Color Variation` cell when filled. With both cells empty, the examples use `4, 3` for town NPCs and `1, 0` or `10, 0` for others; any other pair is a guess until seen in the game.

The pair also picks a second, replacement model for the few models that have one.

## Timing

Waits until the model is loaded. While its script set is suspended it does nothing.

## In NPC Kit

* A file-relative key (`0x03000000 + n`) holds `init` for good, and that stops every talk of the map. Always the absolute key.
* A model whose row says "Results in a crash" crashes the game.
* Each modelled NPC counts toward the map's 64 modelled actors (see `traps.md`).

## Used with

* [setautorelax](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/setautorelax.md)`(1)` and [usecharhit](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/usecharhit.md)`(0)` before it.
* [stdmotionread](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/stdmotionread.md) + [stdmotionreadsync](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/stdmotionreadsync.md) + [stdmotionplay\_2c2](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/stdmotionplay_2c2.md)`(0x01000000, 0)` right after: a model with no motion package stands in a T-pose.
* The rest of the vanilla setup: `placeNpc` in `references/staging.md`.

## Example

```lua
init = function()
    npc.setautorelax(1);
    npc.usecharhit(0);
    npc.bindp2_d4(0x006E0012, 4, 3);       -- Dalmascan Man
    npc.stdmotionread(16);
    npc.stdmotionreadsync();
    npc.stdmotionplay_2c2(0x01000000, 0);
    -- ... position, collision, show
end,
```

## Pitfalls

* Binding a new model in a talk to change an NPC's look waits for the load: the player waits too.
