1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
# npc
The `npc` table is for functions relating directly to the current npc. It is available only in NPC scripts.
---
#### `Vec2F` npc.toAbsolutePosition(`Vec2F` offset)
Returns the specified local position in world space.
---
#### `String` npc.species()
Returns the species of the npc.
---
#### `String` npc.gender()
Returns the gender of the npc
---
#### `Json` npc.humanoidIdentity()
Returns the specific humanoid identity of the npc, containing information such as hair style and idle pose.
---
#### `String` npc.npcType()
Returns the npc type of the npc.
---
#### `uint64_t` npc.seed()
Returns the seed used to generate this npc.
---
#### `float` npc.level()
Returns the level of the npc.
---
#### `List<String>` npc.dropPools()
Returns the list of treasure pools that will spawn when the npc dies.
---
#### `void` npc.setDropPools(`List<String>` pools)
Sets the list of treasure pools that will spawn when the npc dies.
---
#### `float` npc.energy()
Returns the current energy of the npc. Same as `status.resource("energy")`
---
#### `float` npc.maxEnergy()
Returns the current energy of the npc. Same as `status.maxResource("energy")`
---
#### `bool` npc.say(`String` line, [`Map<String,String>` tags], [`Json` config])
Makes the npc say a string. Optionally pass in tags to replace text tags. Optionally give config options for the chat message.
Returns whether the chat message was successfully added.
Available options:
```
{
drawBorder = true,
fontSize = 8,
color = {255, 255, 255},
sound = "/sfx/humanoid/avian_chatter_male1.ogg"
}
```
---
#### `bool` npc.sayPortrait(`String` line, `String` portrait, [`Map<String,String>` tags], [`Json` config])
Makes the npc say a line, with a portrait chat bubble. Optionally pass in tags to replace text tags. Optionally give config options for the chat message.
Returns whether the chat message was successfully added.
Available options:
```
{
drawMoreIndicator = true,
sound = "/sfx/humanoid/avian_chatter_male1.ogg"
}
```
---
#### `void` npc.emote(`String` emote)
Makes the npc show a facial emote.
---
#### `void` npc.dance(`String` dance)
Sets the current dance for the npc. Dances are defined in .dance files.
---
#### `void` npc.setInteractive(`bool` interactive)
Sets whether the npc should be interactive.
---
#### `bool` npc.setLounging(`EntityId` loungeable, [`size_t` anchorIndex])
Sets the npc to lounge in a loungeable. Optionally specify which anchor (seat) to use.
Returns whether the npc successfully lounged.
---
#### `void` npc.resetLounging()
Makes the npc stop lounging.
---
#### `bool` npc.isLounging()
Returns whether the npc is currently lounging.
---
#### `Maybe<EntityId>` npc.loungingIn()
Returns the EntityId of the loungeable the NPC is currently lounging in. Returns nil if not lounging.
---
#### `void` npc.setOfferedQuests(`JsonArray` quests)
Sets the list of quests the NPC will offer.
---
#### `void` npc.setTurnInQuests(`JsonArray` quests)
Sets the list of quests the played can turn in at this npc.
---
#### `bool` npc.setItemSlot(`String` slot, `ItemDescriptor` item)
Sets the specified item slot to contain the specified item.
Possible equipment items slots:
* head
* headCosmetic
* chest
* chestCosmetic
* legs
* legsCosmetic
* back
* backCosmetic
* primary
* alt
---
#### `ItemDescriptor` npc.getItemSlot(`String` slot)
Returns the item currently in the specified item slot.
---
#### `void` npc.disableWornArmor(`bool` disable)
Set whether the npc should not gain status effects from the equipped armor. Armor will still be visually equipped.
---
#### `void` npc.beginPrimaryFire()
Toggles `on` firing the item equipped in the `primary` item slot.
---
#### `void` npc.beginAltFire()
Toggles `on` firing the item equipped in the `alt` item slot.
---
#### `void` npc.endPrimaryFire()
Toggles `off` firing the item equipped in the `primary` item slot.
---
#### `void` npc.endAltFire()
Toggles `off` firing the item equipped in the `alt` item slot.
---
#### `void` npc.setShifting(`bool` shifting)
Sets whether tools should be used as though shift is held.
---
#### `void` npc.setDamageOnTouch(`bool` enabled)
Sets whether damage on touch should be enabled.
---
#### `Vec2F` npc.aimPosition()
Returns the current aim position in world space.
---
#### `void` npc.setAimPosition(`Vec2F` position)
Sets the aim position in world space.
---
#### `void` npc.setDeathParticleBurst(`String` emitter)
Sets a particle emitter to burst when the npc dies.
---
#### `void` npc.setStatusText(`String` status)
Sets the text to appear above the npc when it first appears on screen.
---
#### `void` npc.setDisplayNametag(`bool` display)
Sets whether the nametag should be displayed above the NPC.
---
#### `void` npc.setPersistent(`bool` persistent)
Sets whether this npc should persist after being unloaded.
---
#### `void` npc.setKeepAlive(`bool` keepAlive)
Sets whether to keep this npc alive. If true, the npc will never be unloaded as long as the world is loaded.
---
#### `void` npc.setDamageTeam(`Json` damageTeam)
Sets a damage team for the npc in the format: `{type = "enemy", team = 2}`
---
#### `void` npc.setAggressive(`bool` aggressive)
Sets whether the npc should be flagged as aggressive.
---
#### `void` npc.setUniqueId(`String` uniqueId)
Sets a unique ID for this npc that can be used to access it. A unique ID has to be unique for the world the npc is on, but not universally unique.
|