> 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/model-effects.md).

# Turning and Effects

**Three calls of NPC Kit's own for how a model looks: turned on all three axes, given a character effect, and that effect tinted.**

{% hint style="warning" %}
**Experimental.** No VM call does these: NPC Kit writes the model's render state itself. They may change between versions.
{% endhint %}

| call                      | what it does                                                                                          |
| ------------------------- | ----------------------------------------------------------------------------------------------------- |
| `npc.rotate(x, y, z)`     | turns the model on all three axes, in radians                                                         |
| `npc.efx(h)`              | gives the model the character effect `chara\h<h>.efx`, in place of its own; `npc.efx(0)` takes it off |
| `npc.efxrgba(r, g, b, a)` | tints the model's effect, each channel 0 to 255, 128 as drawn                                         |

All three go inside a function of `npc.add`, like any call, and act on the NPC whose function it is. They need the model built: put them after `show` in `init`, or in a function the talk or `init` runs later.

***

### rotate

`x` is applied first; `y` is the heading `npc.dir` sets. z holds until the model turns again (a `dir`, a turn, a walk), so keep `rotate` for things that stay put: a sword stuck in the ground, a bottle on its side.

```lua
npc.rotate(1.601, -0.392, -0.107);   -- a bottle lying on the floor
```

A model off the walkmesh (`usemapid(0)`) keeps the Y of `setpos2`, which is what places a turned object on a table or the floor.

***

### efx

`h` is the effect's number, `h0034` being `34`. The effect comes with the model of the monster or object that owns it: NPC Kit reads that model first (it never appears), and the script waits while it loads. Each `h` and its model is in `NPCKit/Effects.lua`; the [editor](https://fehdead.gitbook.io/npc-kit/editor.md) lists them.

```lua
npc.efx(34);    -- a Purobolos's flame
npc.efx(0);     -- no effect
```

The effect replaces the one the model had. A map holds 32 effect packages and 32 effects at once, its own among them; past that `efx` does nothing and says so in `hook.log`.

***

### efxrgba

Tints the effect the model has, from `efx` or its own (a save crystal's look is one). 128 on every channel is the effect as drawn; the effect starts over in the new colour. Without an effect it does nothing and says so in `hook.log`.

```lua
npc.efx(118);
npc.efxrgba(0, 255, 139, 247);
```

The effect also takes the model's transparency: an NPC faded with `rgbatrans` fades its effect with it.

See them together in [A Magic Sword](https://fehdead.gitbook.io/npc-kit/examples/magic-sword.md) and [A Quest: The Bhujerban Viper](https://fehdead.gitbook.io/npc-kit/examples/drink-quest.md).
