NPCs

From giving out quests, to telling jokes, NPCs help drive players forward

Interactor

Load

Command
Scripting
Command

/kit create <id> [mode] [-i]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • -i will set the kits contents to the items in your inventory

Scripting

- run drustcraft.interactor.load

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • ontents.

Determinations

  • err_not_permitted - Player does not have permission for this command

  • err_id_missing - No kit id was passed to the task

  • err_id_exists - Kit id already exists

  • err_kit_mode_invalid - Kit mode is not a valid mode (see Kit Modes)

NPC Set

Command
Scripting
Command

/kit create <id> [mode] [-i]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • -i will set the kits contents to the items in your inventory

Scripting

- run drustcraft.interactor.npc def:<npc-id>|<task-name>

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • ontents.

Determinations

  • err_not_permitted - Player does not have permission for this command

  • err_id_missing - No kit id was passed to the task

  • err_id_exists - Kit id already exists

  • err_kit_mode_invalid - Kit mode is not a valid mode (see Kit Modes)

NPC Get

Command
Scripting
Command

/kit create <id> [mode] [-i]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • -i will set the kits contents to the items in your inventory

Scripting

- <proc[drustcraftp.interactor.npc].context[<npc-id>]>

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • ontents.

Determinations

  • err_not_permitted - Player does not have permission for this command

  • err_id_missing - No kit id was passed to the task

  • err_id_exists - Kit id already exists

  • err_kit_mode_invalid - Kit mode is not a valid mode (see Kit Modes)

interactor tasks

definitions:

1 - NPC ID

2 - Player

3 - Command

Commands

close: force close any interactions between player and npc

click: player clicked on npc

enter: player entered range of NPC

exit: player exited range of NPC

NPCs are an intrigual part of the Drustcraft universe, whether to help fill in a space with livelyness, providing players with vital items, or giving the experience of rowing a boat across the open seas.

NPCs are made available in Drustcraft by the Citizens plugin, and are referenced in Drustcraft by their unique ID number. Each NPCs data is stored in the npcs.yml file and can be manipulated using the /dc npc command.

Drustcraft uses roles to assign scripting NPC roles. Traits is reserved for Citizens

Builders do not need permission to any of the Citizens commands in order to create, manipulate or remove a NPC.

YML Format

npcs:
<npc-id>:
name: <npc-name>
enabled: [true|false]
location: <npc-spawn-location>
skin: <skin-id>
traits:
- <trait-1>
- <trait-2>
- ...
group: <npc-group-id>
greetings:
[anytime|day|night|dawn|dusk]:
[any|clear|overcast|raining|snowing|thunder]:
- Hello $NAME$, isnt this a great day!
- ...
npcgroups:
nameprefix: <name-prefix>
greetings:
[anytime|day|night|dawn|dusk]:
[any|clear|overcast|raining|snowing|thunder]:
- Hello $NAME$, isnt this a great day!

Greetings

NPC greetings are displayed to the player when they are right clicked on by the player. In some instances when an NPC has a trait applied (ie shopkeeper), a player may not see a greeting until they are finished interacting with that trait (ie when they close the shopkeeper inventory).

Greetings can contain placeholders which will be expanded when displayed to the user.

Priority

Greetings can be set either in a NPC group to apply to all NPCs within that group, or on the NPC itself. If a NPC has its own greeting set, any greeting set in the NPC group will be ignored.

Anytime vs Dawn, Any vs Raining

You can customize a NPCs greeting based on the time-period and the current weather conditions. If you include the anytime and/or the any keys, these greetings will be included in the pool of greeting to randomally choose from when displaying a greeting to the user.

Conditional Greetings

Greetings can also be conditional based on a players past experiences.

To include a greeting if a player has experienced a quest, entered an arena, or other supported conditon, your greeting must begin with the + character.

Alternatively, to exclude a greeting is a player has not experienced a quest or other supported condition, begin your greeting with the - character.

To specify the condition, you use a special format of characters after the + or - character followed by a space.

Quests - quest:[Quest-ID]

Add the greeting wow you found Marks landing when a player completes quest ID 14: +quest:14 Wow you found Marks landing

Arena - arena:[Arena-ID]

Add the greeting you seem really good at hide and seek when a player has been in the hide and seek (hidenseek) arena: +arena:hidenseek You seem really good at hide and seek Region - region:[Region-ID]

Add the greeting Have you visited Rowe and build something cool? when a player has not been to the region rowe: -region:rowe Have you visited Rowe and built something cool?

Scripting Conditional Greetings

To add a new conditional greeting, you simply register it in your script using the following command:

- run drustcraft.npc.greeting.conditional.register def:<code>|<task-name>

Whenever the NPC engine calculates which greeting to use, the NPC engine will call your task when it comes across a greeting that uses a conditional greeting that contains the conditional code you registered.

Conditional greeting tasks are called with the following definitions:

[1] - If the conditional greeting is set to + or - [2] - The conditional code specified (this allows you to use the same task for multiple registrations) [3] - The data specified in the greeting (ie the ID or text after the character code)

As an example, if I wanted to create a conditional greeting based on if the player has ever placed a gravel block, I would need to implement the following code (including the block-place event to detect if the player has ever placed the gravel block):

myexample_world:
type: world
events:
on drustcraft load:
- run drustcraft.npc.greeting.conditional.register def:placed_gravel|myexample_task
on player places block:
- if <context.block.material.name||<empty>> == gravel:
- flag player myexample_placed_gravel:true
myexample_task:
type: task
script:
- if <[2]||<empty>> == 'placed_gravel':
- if <[1]||<empty>> == '-' && <player.flag[myexample_placed_gravel]||false> == false:
- determine true
- if <[1]||<empty>> == '+' && <player.flag[myexample_placed_gravel]||false> == true:
- determine true
- determine false

And now I could use the condtional greeting +placed_gravel some greeting. Notice that in this example, we are not using the ID or data component. If we did want to use an ID or data component, it would be defined to the script as [3].

/qm npc list
/qm npc create <name>
/qm npc remove
/qm npc enable
/qm npc disable
/qm npc move
/qm npc rename <new_name>
/qm npc trait registered
/qm npc trait list
/qm npc trait add <trait>
/qm npc trait remove <trait>
/qm npc select <npc>
/qm npc group
/qm npc group set <group>
/qm npc group remove
<proc[qm_npc.list]>
<proc[qm_npc.exists].context[id]>+
<proc[qm_npc.find].context[name]>+
<proc[qm_npc.get.name].context[id]>
<proc[qm_npc.get.location].context[id]>
<proc[qm_npc.get.trait].context[id]>
qm_npc.create def:name
qm_npc.remove def:(name|id)
qm_npc.despawn def:(name|npc)
qm_npc.remove def:(name|npc)
qm_npc.rename def:(old_name|npc)|new_name
qm_npc.trait.register def:trait
qm_npc.trait.add def:(name|npc)|trait
qm_npc.trait.remove def:(name|npc)|trait
qm_npc.data.set def:(name|npc)|key|value
proc[qmp_npc.trait].context[(name|npc)]
proc[qmp_npc.data.get].context[(name|npc)|key]

Events for Traits

on trait_<trait>_proximity_entry
on trait_<trait>_proximity_exit
on trait_<trait>_player_click
on trait_<trait>_add
on trait_<trait>_remove
on trait_<trait>_load? - just use on load?
on trait_<trait>_save? - just use on save?