alloc

fun alloc(index: Int, id: Int, level: Int, x: Int, z: Int, spawnCycle: Int = 0, direction: Int = 0): NpcAvatar

Allocates a new NPC avatar, or re-uses an older cached one if possible.

Npc direction table:

| Id | Client Angle |  Direction |
|:--:|:------------:|:----------:|
| 0 | 768 | North-West |
| 1 | 1024 | North |
| 2 | 1280 | North-East |
| 3 | 512 | West |
| 4 | 1536 | East |
| 5 | 256 | South-West |
| 6 | 0 | South |
| 7 | 1792 | South-East |

Return

a npc avatar with the above provided details.

Parameters

index

the index of the npc in the world

id

the id of the npc in the world, limited to range of 0..16383

level

the height level of the npc

x

the absolute x coordinate of the npc

z

the absolute z coordinate of the npc

spawnCycle

the game cycle on which the npc spawned into the world; for static NPCs, this would always be zero. This is only used by the C++ clients.

direction

the direction that the npc will face on spawn (see table above)