Npc Avatar
The npc avatar class represents an NPC as shown by the client. This class contains all the properties necessary to put a NPC into high resolution.
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 |Parameters
the index of the npc in the world
the id of the npc in the world, limited to range of 0..16383
the height level of the npc
the absolute x coordinate of the npc
the absolute z coordinate of the npc
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.
the direction that the npc will face on spawn (see table above)
the priority that the avatar will have. The default is AvatarPriority.NORMAL. If the priority is set to AvatarPriority.LOW, the NPC will only render if there are enough slots leftover for the low priority group. As an example, if the low priority cap is set to 50 elements and there are already 50 other low priority avatars rendering to a player, this avatar will simply not render at all, even if there are slots leftover in the AvatarPriority.NORMAL group. For AvatarPriority.NORMAL, both groups are accessible, although they will prefer the normal group. Low priority group will be used if normal group has no more free slots leftover. The priorities are especially useful to limit how many pets a player can see at a time. It is very common for servers to give everyone pets. During high population events, it is very easy to hit the 250 pet threshold in a local area, which could result in important NPCs, such as shopkeepers and whatnot from not rendering. Limiting the low priority count ensures that those arguably more important NPCs will still be able to render with hundreds of pets around.
if true, the NPC will only render to players that have explicitly marked this NPC's index as specific-visible, anyone else will be unable to see it. If it's false, anyone can see the NPC regardless.
Properties
the extended info, commonly referred to as "masks", will track everything relevant inside itself. Setting properties such as a spotanim would be done through this. The extendedInfo is also responsible for caching the non-temporary blocks, such as appearance and move speed.
the storage tracking all the allocated game NPCs based on the zones.
Functions
Checks the number of players that are currently observing this NPC avatar.
Gets a set of all the indexes of the players that are observing this NPC.
Handles any changes to be done to the avatar post its update. This will clean up any extended info blocks and update the last coordinate to match up with the current (set earlier in the cycle).
Updates the spawn direction of the NPC.
Sets this avatar inaccessible, meaning no player can observe this NPC, but they are still in the world. This is how NPCs in the 'dead' state will be handled.
A helper function to teleport the NPC to a new coordinate. This will furthermore mark the movement type as teleport, meaning no matter what other coordinate changes are applied, as teleport has the highest priority, teleportation will be how it is rendered on the client's end.
Updates the spawn direction of the NPC.