Date: 2015/11/07 11:24:38 UTC-08:00
Type: Denizen Script
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
# Talker
#
# This scripts is for NPCs with a defined path using the /npc path feature on citizens
# The Talker_i is a dummy example of a NPC who talks witht he user.
# A task Wait_on_place is defined to stop the npc to keep walking on its path durgin conversation
#
# Note: The NPC walks a few steps more before halt the path.
#
# inspired by @author narnian
# buchered by m1fly
Talker:
type: assignment
actions:
on assignment:
- trigger name:chat toggle:true
- trigger name:click toggle:true
- trigger name:proximity toggle:true
interact scripts:
- 10 Talker_i
Talker_i:
type: interact
steps:
First*:
proximity trigger:
Entry Radius: 5
Exit Radius: 5
Entry:
Script:
#The player enters on radius, so the NPC asks a question
- CHAT 'Hello, how are you today?'
#The NPC waits for the answer, we set the flag to stop the movement and call the task to stop/move the NPC
- flag npc "AllowedToMove:0"
- ZAP 'SCRIPT:Talker_i' step:Second
- runtask "script:Wait_on_place"
Second:
chat trigger:
1:
Trigger: /fine/ thank you
script:
#If the player answers, the NPC says something and change the falg to keep moving
- CHAT "Nice to know"
- flag npc "AllowedToMove:1"
- ZAP 'SCRIPT:Talker_i' step:First
2:
Trigger: very /good/ and you?
script:
- CHAT "Ohh Im great"
- flag npc "AllowedToMove:1"
- ZAP 'SCRIPT:Talker_i' step:First
#unexpected answer
3:
Trigger: /REGEX:\w+/
script:
- CHAT "Sorry, I did not understand"
- flag npc "AllowedToMove:1"
- ZAP 'SCRIPT:Talker_i' step:First
Wait_on_place:
Type: Task
Script:
- flag npc "wait_xposwait:<npc.location.x>"
- flag npc "wait_xposwait:++"
- flag npc "wait_maxwaiting:0"
- if <flag.n:AllowedToMove> == 0 runtask "script:Wait_on_place_loop"
Wait_on_place_loop:
Type: Task
Script:
- walkto "location:<flag.n:wait_xposwait>,<npc.location.y>,<npc.location.z>,<npc.location.world>" "speed:0.00001"
- flag npc "wait_maxwaiting:++"
#There is a maximum time the NPC will wait for an answer, if you increase the number on the condition the NPC will wait more time
- if <flag.n:wait_maxwaiting> == 15 flag npc "AllowedToMove:1"
- if <flag.n:AllowedToMove> == 0 runtask "script:Wait_on_place_loop"