Date: 2017/02/11 00:36:28 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
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
# NPC Townsmen
# Citizens 2 (build #992)
# Denizen 0.9.3 (build #1352)
#
# @author Hyruii
#
# FOR EASY SETUP
# 1) Press ctr-h to find all 'world10' and replace with your server name.
# 2) Replace all locations in "globaltime" with your own x,y,z,world.
# 3) Put levers inside their homes beside their doors.
# 4) Create anchors named 'home' for each Townsmen NPC, which is located inside their house. (within 3 blocks from their door)
# 5) Select the NPC and type /npc assign --set "townsmen"
"globaltime":
type: world
events:
on server start:
# Flag all the town locations.
# Location of Blacksmith
- ^flag global "Blacksmith:l@778,77,1038,world10"
# Location of Farm
- ^flag global "Farm:l@852,76,1032,world10"
# Location of General Shop
- ^flag global "General:l@819,76,1036,world10"
# Location of Park
- ^flag global "Park:l@220,64,810,world10"
# Location of Inn
- ^flag global "Inn:l@230,70,791,world10"
# Location of Cafe
- ^flag global "Cafe:l@223,65,820,world10"
# Use your own server name to replace world10
on 6:00 in world10:
# Loop checking trait of list of NPC assigned as townsmen.
- foreach <fl@npclist.as_list> {
- run npcid:%value% wake
}
# Use your own server name to replace world10
on 11:00 in world10:
# Loop checking trait of list of NPC assigned as townsmen.
- foreach <fl@npclist.as_list> {
- run npcid:%value% lunch
}
# Use your own server name to replace world10
on 13:00 in world10:
# Loop checking trait of list of NPC assigned as townsmen.
- foreach <fl@npclist.as_list> {
- run npcid:%value% work
}
# Use your own server name to replace world10
on 18:00 in world10:
# Loop checking trait of list of NPC assigned as townsmen.
- foreach <fl@npclist.as_list> {
- run npcid:%value% sleep
}
"townsmen":
type: assignment
interact scripts:
# Priority starts from 10.
- 10 Townsmen Chat
actions:
on assignment:
# These triggers enable/disable interaction with an NPC via chatting, clicking and entering proximity.
- trigger name:chat toggle:false
- trigger name:click toggle:false
- trigger name:proximity toggle:true radius:2
# Add NPC id to npclist upon assignment.
- if <fl@npclist.as_list> contains '<npc.id>' {
- narrate 'I am already a townsmen'
}
else {
- flag global "npclist:->:<npc.id>"
}
# on despawn:
on complete navigation:
# Check that if NPC has walked home, it will close the door.
# If NPC is at lunch, eating/drinking sound will play.
- if <npc.location.simple> equals <npc.anchor[home].simple> {
- define hlever <npc.location.find.blocks[lever].within[1.1]>
- foreach %hlever% {
- switch %value% state:off
}
}
else {
- if <npc.location.simple> equals <flag.global:[Tavern|Cafe].simple> {
- random 2
- playsound <npc.location> sound:eat
- playsound <npc.location> sound:drink
}
}
on remove assignment:
# Removes NPC id from npclist upon another assignment.
- flag global "npclist:<-:<npc.id>"
on remove:
# Removes NPC id from npclist upon removal.
- flag global "npclist:<-:<npc.id>"
"Townsmen Chat":
type: interact
steps:
1:
proximity trigger:
entry:
script:
# Replace world10 with own server name.
- define greeting "<w@world10.time.period>"
- narrate "<npc.name> smiles at you."
- chat "Good %greeting%, <player.name>."
wake:
type: task
script:
# NPC will use switch to open the door and walk to a location.
# NPC will use switch inside house to open the door.
- define hlever <npc.location.find.blocks[lever].within[1.1]>
- foreach %hlever% {
- switch %value% state:on
}
# NPC will randomly choose a location to visit.
- random 4
- inject locally blacksmith
- inject locally farm
- inject locally general
- inject locally park
blacksmith:
- equip shears
- walk <flag.global:Blacksmith> speed:0.8 auto_range
farm:
- equip stone_hoe
- walk <flag.global:Farm> speed:0.8 auto_range
general:
- equip paper
- walk <flag.global:General> speed:0.8 auto_range
park:
- equip red_rose
- walk <flag.global:Park> speed:0.8 auto_range
lunch:
type: task
script:
# NPC will randomly choose the inn/tavern/cafe to walk to for lunch.
- random 2
- walk <flag.global:Inn> speed:0.8 auto_range
- walk <flag.global:Cafe> speed:0.8 auto_range
work:
type: task
script:
# NPC will randomly choose a location to walk to.
- random 4
- inject locally blacksmith
- inject locally farm
- inject locally general
- inject locally park
blacksmith:
- equip shears
- walk <flag.global:Blacksmith> speed:0.8 auto_range
farm:
- equip stone_hoe
- walk <flag.global:Farm> speed:0.8 auto_range
general:
- equip paper
- walk <flag.global:General> speed:0.8 auto_range
park:
- equip red_rose
- walk <flag.global:Park> speed:0.8 auto_range
sleep:
type: task
script:
# Stops the NPC wandering and make it walk home.
- walk <npc.anchor[home]> speed:0.8 auto_range