Date: 2014/03/23 15:56:49 UTC-07: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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
"Lumberjack":
type: assignment
default constants:
logs: oak_log|birch_log|spruce_log
leaves: leaves|birch_leaves|spruce_leaves
initialRange: 5
interact scripts:
- 10 Lumberjack life
actions:
on assignment:
- trigger name:proximity toggle:true
- anchor add l@-3510,67,13,Azeroth id:home
- anchor add l@-3521,67,13,Azeroth id:startPosition
- anchor add l@-3518,67,16,Azeroth id:restPosition
- anchor add l@-3508,68,12,Azeroth id:sleepPosition
- note cu@-3523,65,3,Azeroth|-3500,77,24,Azeroth as:ForesterLodge
- equip <npc> hand:i@258 chest:i@299 legs:i@300 boots:i@301
# ------ Add NPC to default Sleepcycle list -----------------------
- if <server.has_flag[defaultSleepNpcList]> {
- if <global.flag[defaultSleepNpcList].as_list> !contains <npc> {
- flag global defaultSleepNpcList:->:<npc>
}
} else {
- flag global defaultSleepNpcList:!
- flag global defaultSleepNpcList:->:<npc>
}
# ------ Add NPC to Countryman Workcycle list ---------------------
- if <server.has_flag[CountryWorker]> {
- if <global.flag[CountryWorker].as_list> !contains <npc> {
- flag global CountryWorker:->:<npc>
}
} else {
- flag global CountryWorker:!
- flag global CountryWorker:->:<npc>
}
on complete navigation:
- if <npc.location.simple> equals <npc.anchor[home].simple> {
- if <npc.flag[ready_to_sleep]> {
- run "fallAsleep"
}
} else if <npc.location.simple> equals <npc.anchor[startPosition].simple> {
- if <npc.flag[ready_to_work]> {
- run "StartChopping"
} else {
- run "fillChest"
}
} else {
- if <npc.flag[isWorking]> {
- run "defineTree"
}
}
#------ Interact scripts for NPC ------
"Lumberjack Life":
type: interact
Requirements:
Mode: ALL
steps:
1:
proximity trigger:
entry:
script:
- run "Greetings"
# ------ Lumberjack specific tasks ------
"StartChopping":
type: task
script:
- flag npc gatheredLogs:0
- flag npc isWorking:true
- run "lookForTrees"
"lookForTrees":
type: task
script:
- flag npc found_tree:!
- flag npc actualRange:<cons:initialRange>
- foreach <npc.location.find.blocks[<npc.constant[logs]>].within[<npc.flag[actualRange]>].as_list> {
- if <proc[isTreeHump].context[%value%]> {
- if !<proc[isHome].context[%value%]> {
- flag npc found_tree:|:%value%
}
}
}
- if <npc.flag[found_tree].size.as_int> == 0 {
- flag npc actualRange:++:5
- run "lookForTrees"
} else {
- ~walk <npc> <npc.flag[found_tree].get[1]> auto_range
}
}
"defineTree":
type: task
script:
- look <npc> <npc.flag[found_tree].get[1]>
- flag npc tree_elems:!
- flag npc tree_elems:|:<npc.flag[found_tree].get[1]>
- flag npc current_elem:1
- run "checkBlockAbove"
"checkBlockAbove":
type: task
script:
- define currentBlock <npc.flag[tree_elems].get[<npc.flag[current_elem].as_int>]>
- if <proc[isLogAbove].context[%currentBlock%]> {
- animate <npc> animation:arm_swing
- flag npc tree_elems:|:<%currentBlock%.above>
- flag npc current_elem:++
- run "checkBlockAbove"
} else {
- flag npc gatheredLogs:++:<npc.flag[tree_elems].size.as_int>
- run "lookForLeaves"
}
"lookForLeaves":
type: task
script:
- define topBlock <npc.flag[tree_elems].get[<npc.flag[tree_elems].size.as_int>]>
- foreach <%topBlock%.find.blocks[<npc.constant[leaves]>].within[3].as_list> {
- flag npc tree_elems:|:%value%
}
- run "cutTree"
"cutTree":
type: task
script:
- foreach <npc.flag[tree_elems].as_list> {
- modifyblock %value% 0
}
- narrate targets:p@NLS667 "Tree was cut."
- if <npc.flag[found_tree].get[1].below.material.id> != 1 {
- modifyblock <npc.flag[found_tree].get[1]> 6
- narrate targets:p@NLS667 "Tree was planted."
}
- run "lookForTrees"
"fillChest":
type: task
script:
- narrate targets:p@NLS667 "I added <npc.flag[gatheredLogs].as_int> logs to chest."
"isHome":
type: procedure
definitions: block
script:
- if <cu@ForesterLodge.is_within[%block%]> {
- ^determine true
} else {
- ^determine false
}
"isLogAbove":
type: procedure
debug: false
definitions: block
script:
- if <%block%.above.material.id> == <%block%.material.id> {
- ^determine true
} else {
- ^determine false
}
"isTreeHump":
type: procedure
debug: false
definitions: block
script:
- ^if <%block%.below.material.id> == 3 || <%block%.below.material.id> == 1 {
- if <%block%.above.material.id> == <%block%.material.id> {
- ^determine true
} else {
- ^determine false
}
} else {
- ^determine false
}
#------ default NPC tasks ------
"Greetings":
type: task
script:
- chat targets:p@<player.name> "Hello there traveler!"
"wakeUp":
type: task
script:
- flag <npc> ready_to_sleep:!
- animate <npc> animation:stop_sleeping
- ~walk <npc> <npc.anchor[home].simple> auto_range
"workTime":
type: task
script:
- flag <npc> ready_to_work:true
- ~walk <npc> <npc.anchor[startPosition].simple> auto_range
"freeTime":
type: task
script:
- flag <npc> ready_to_work:!
- flag <npc> isWorking:!
- queue clear
- ~walk <npc> <npc.anchor[startPosition].simple> auto_range
"goToSleep":
type: task
script:
- flag <npc> ready_to_sleep:true
- ~walk <npc> <%npc%.anchor[home].simple> auto_range
"fallAsleep":
type: task
script:
- ~walk <npc> <npc.location.find.blocks[i@355].within[3].get[1]> auto_range
- animate <npc> animation:sleep
- queue clear