Date: 2020/01/04 18:37:34 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
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
world_script:
type: world
events:
#todo
#/ex narrate "<server.list_notables>"
#convert to - flag server cuboids:notabe/owner
on world loads:
- if <server.flag[index]>|| null == null:
- flag server index:1
- if <farmcube||null> == null:
- note <cuboid[0,0,0,world|0,0,0,world]> as:farmcube
#mayor creation
on player right clicks stone_bricks with wheat:
- take iteminhand
- drop mayor_placer <context.location>
on player right clicks block with mayor_placer:
- if !<player.has_flag[has_mayor]>:
- take iteminhand
- create player mayor <context.location.add[0,2,0]> save:mayorID
- assignment set script:mayor_assignment npc:<entry[mayorID].created_npc>
- adjust <entry[mayorID].created_npc> owner:<player.name>
- adjust <entry[mayorID].created_npc> lookclose:true
- flag player has_mayor:<entry[mayorID].created_npc>
- determine cancelled
- else:
- narrate "you already have a mayor"
- narrate "dismiss your mayor to spawn a new one"
- narrate "or type /resetmayor to remove your mayor"
- determine cancelled
#mayor creation end
##mayor interactions
##
##
#create a soldier npc
on player clicks mayor_hire_soldier in mayor_menu:
- if <player.inventory.quantity.material[wheat]> >= 64 && <player.flag[soldier]||0> < 5:
- take wheat quantity:64
- narrate "you hired a soldier"
- create player soldier <player.location.add[0,2,0]> trait:sentinel save:soldierID
- flag player soldier:++
- assignment set script:soldier_assignment npc:<entry[soldierID].created_npc>
#configure soldier as sentinel owned by player
- adjust <entry[soldierID].created_npc> owner:<player.name>
- adjust <entry[soldierID].created_npc> speed:1.3
- execute as_op "npc select <entry[soldierID].created_npc.id>" silent
- execute as_op "npc skin --url https://i.imgur.com/nwUVLKc.png" silent
- execute as_server "sentinel chaserange 15 --id <entry[soldierID].created_npc.id>"
- execute as_server "sentinel addtarget monsters --id <entry[soldierID].created_npc.id>"
- execute as_server "sentinel guard <player.name> --id <entry[soldierID].created_npc.id>"
- execute as_server "sentinel attackrate 1 --id <entry[soldierID].created_npc.id>"
- execute as_server "sentinel realistic --id <entry[soldierID].created_npc.id>"
- execute as_server "sentinel safeshot true --id <entry[soldierID].created_npc.id>"
- execute as_server "sentinel speed 1.5 --id <entry[soldierID].created_npc.id>"
- execute as_server "sentinel respawntime -1 --id <entry[soldierID].created_npc.id>"
- inventory open d:mayor_menu
- determine cancelled
- else:
- if <player.flag[soldier]> > 5:
- narrate "soldier limit reached for mayor(5)"
- determine cancelled
- else:
- narrate "you dont have enough wheat"
- determine cancelled
#soldier creation end
#create a farmer npc
on player clicks mayor_hire_farmer in mayor_menu:
- if <player.inventory.quantity.material[iron_ingot]> >= 10 && <player.flag[farmer]||0> < 3:
- take iron_ingot quantity:10
- narrate "you hired a farmer"
- create player farmer <player.location.add[0,2,0]> save:farmerID
- flag player farmer:++
- assignment set script:farmer_assignment npc:<entry[farmerID].created_npc>
- adjust <entry[farmerID].created_npc> owner:<player.name>
- inventory open d:mayor_menu
- determine cancelled
- else:
- if <player.flag[farmer]> > 5:
- narrate "farmer limit reached for mayor(3)"
- determine cancelled
- else:
- narrate "you dont have enough iron"
- determine cancelled
#create farmer end
#remove the npc the player is talking with
on player clicks mayor_dismiss in mayor_menu:
- narrate "goodbye"
- remove <npc[<player.flag[interact_ID]>]>
- flag player has_mayor:!
- inventory close
- determine cancelled
on npc death:
#todo FIX
- flag <npc.owner> <npc.name>:--
- note remove as:<npc.id>
on player left clicks with air:
- if <player.has_flag[equiping]> && <player.is_sneaking>:
- execute as_op "npc equip"
- flag player equiping:!
- determine cancelled
- if <player.has_flag[pathing]> && <player.is_sneaking>:
- execute as_op "npc path"
- execute as_op "sentinel guard"
- narrate "the soldier will now guard this area"
- flag player pathing:!
- determine cancelled
##
##
##
#soldier interactions
##
##
##
on player clicks soldier_equip in soldier_menu:
- if !( player.flag[equiping] == <player.flag[interact_ID]> ) && !<player.has_flag[pathing]>:
- execute as_op "npc select <player.flag[interact_ID].as_npc.id>" silent
- execute as_op "npc equip"
- narrate "<yellow>Shift left click <green>with an empty hand to exit"
- flag player equiping:!|:<player.flag[interact_ID]>
- inventory close
- determine cancelled
- else:
- inventory close
- wait 8t
- narrate "already equiping a soldier or assigning waypoints"
- determine cancelled
on player clicks soldier_path in soldier_menu:
- if !( player.flag[pathing] == <player.flag[interact_ID]> ) && !<player.has_flag[pathing]>:
- execute as_op "npc select <player.flag[interact_ID].as_npc.id>" silent
- execute as_op "npc path"
- flag player pathing:!|:<player.flag[interact_ID]>
- inventory close
- determine cancelled
- else:
- inventory close
- wait 8t
- narrate "already assigning waypoints or equiping a soldier"
- determine cancelled
on player clicks soldier_guard in soldier_menu:
- execute as_op "sentinel guard <player.name> --id <player.flag[interact_ID].as_npc.id>"
- narrate "soldier is now following"
- determine cancelled
#remove the npc the player is interacting with
on player clicks soldier_dismiss in soldier_menu:
- narrate "goodbye"
- remove <npc[<player.flag[interact_ID]>]>
- flag player soldier:--
- inventory close
- determine cancelled
##
##
##
#farmer interactions
##
##
on player clicks farmer_area in farmer_menu:
- narrate "right click corners with an empty hand to mark the area"
- narrate "shift click with an empty hand to cancel"
- flag player editing:<player.flag[interact_ID]>
- flag player farming:1
- inventory close
- determine cancelled
#defining farm area and add to farm cube
on player right clicks block with air:
- if <player.flag[farming]> == 1:
- narrate "corner set at <context.location.xyz.replace[,].with[ ]>"
- flag player corner1:<context.location>
- flag player farming:++
- determine cancelled
- else:
- if <player.flag[farming]> == 2:
- define new_area:<cuboid[<player.flag[corner1]>|<context.location>]>
- define area_name:<server.flag[cuboids].map_get[<player.flag[editing]>]>
- define area_index:<server.flag[cuboids].map_get[<player.flag[editing]>].replace[farm_area_]>
#check if the player is overwriting a previous region
- if <[area_name].length> > 3:
#overwrites the old cuboid with one at 0.0.0 so it does not intersect with the previous area
- note <farmcube.add_member[cuboid[0,0,0,world|0,0,0,world]].at[[area_index]]> as:farmcube
#if the new area does not overlap another area replace the old area and add it to the world area
- if !<cuboid[farmcube].intersects[new_area]>:
- note new_area as:farm_area_[area_index]
- note <cuboid[farmcube].add_member[new_area]> as:farmcube
#if it overlaps restore the previous area to the farm cube and return an error
- else:
- narrate "Error: this area overlaps another farm area &nl Restoring previous area &nl right click to select a new are &nl shift left click to cancel"
- note <cuboid[farmcube].add_member[<cuboid[[area_name]]>]> as:farmcube
#restarts the new area definition
- flag player farming:1
- determine cancelled
#else create a new one with the next available index
- else:
- if !<cuboid[farmcube].intersects[new_area]>:
#create the farm area and add it to the farm cube and cuboids list
- note new_area as:farm_area_<server.flag[index]>
#list the npc that the area belongs to and advance the index for the next area
- flag server cuboids:->:<player.flag[editing]>/farm_area_<server.flag[index]>
- flag server index:++
- note <cuboid[farmcube].add_member[new_area]> as:farmcube
- narrate "farm area created"
- flag player farming:!
- determine cancelled
- else:
#if it overlaps restore the previous area to the farm cube and return an error
- narrate "Error: this area overlaps another farm area &nl Restoring previous area &nl right click to select a new are &nl shift left click to cancel"
- note <cuboid[farmcube].add_member[<cuboid[<area_name>]>]> as:farmcube
- flag player farming:1
- determine cancelled
##
##
#world events
##
##
##
on wheat grows in:farmcube:
- wait 1t
- if <context.location.material> == <material[wheat[age=7]]>:
#if the location is contained within a cuboid
- if <context.location.cuboids.get[2].notable_name||null> == farmcube:
- adjust <npc[<list[<server.flag[cuboids]>].map_get[<area_id>]>]> add_waypoint:<context.location.center>
- adjust <npc[<list[<server.flag[cuboids]>].map_get[<area_id>]>]> clear_waypoints
mayor_assignment:
type: assignment
actions:
on assignment:
- trigger name:click state:true
interact scripts:
- 1 mayor_interact
soldier_assignment:
type: assignment
actions:
on assignment:
- trigger name:click state:true
interact scripts:
- 1 soldier_interact
farmer_assignment:
type: assignment
actions:
on assignment:
- trigger name:click state:true
interact scripts:
- 1 farmer_interact
mayor_interact:
type: interact
steps:
1:
click trigger:
script:
#open the menu and flag the npc as the one being interacted with
- if <player> == <npc.owner>:
- inventory open d:mayor_menu
- flag player interact_ID:<npc>
- else:
- narrate "this person does not obey you"
soldier_interact:
type: interact
steps:
1:
click trigger:
script:
#open the menu if the player owns the npc and flag the npc as the one being interacted with
- if <player> == <npc.owner>:
- inventory open d:soldier_menu
- flag player interact_ID:<npc>
- else:
- narrate "this soldier does not obey you"
farmer_interact:
type: interact
steps:
1:
click trigger:
script:
#open the menu and flag the npc as the one being interacted with
- if <player> == <npc.owner>:
- inventory open d:farmer_menu
- flag player interact_ID:<npc.id>
- else:
- narrate "this person does not obey you"
mayor_menu:
type: inventory
title: Mayor
size: 27
slots:
- "[mayor_dismiss] [] [] [] [] [] [] [] []"
- "[] [] [] [mayor_hire_farmer] [mayor_hire_soldier] [] [] [] []"
- "[] [] [] [] [] [] [] [] []"
soldier_menu:
type: inventory
title: Soldier
size: 9
slots:
- "[soldier_dismiss] [] [] [soldier_equip] [soldier_path] [soldier_guard] [] [] []"
farmer_menu:
type: inventory
title: Farmer
size: 27
slots:
- "[] [] [] [] [] [] [] [] []"
- "[] [] [] [] [farmer_area] [] [] [] []"
- "[] [] [] [] [] [] [] [] []"
mayor_placer:
type: item
material: bat_spawn_egg
display name: Mayor spawner
mayor_hire_soldier:
type: item
material: stone_sword
display name: Hire a soldier for 64 Wheat (<player.flag[soldier]>/5)
mayor_hire_farmer:
type: item
material: stone_hoe
display name: Hire a farmer for 10 iron ingots
mayor_dismiss:
type: item
material: barrier
display name: Dismiss the mayor
soldier_path:
type: item
material: arrow
display name: set the patrol path
soldier_guard:
type: item
material: shield
display name: guard the player
soldier_equip:
type: item
material: iron_chestplate
display name: equip your soldier
soldier_dismiss:
type: item
material: barrier
display name: Dismiss this soldier
farmer_area:
type: item
material: farmland
display name: set farming area
reset_command:
type: command
name: reset
description: resets variables
usage: /reset (type)
tab complete:
- determine <list[mayor|farms]>
script:
- if <context.args.get[1]> == farms:
- note <cuboid[0,0,0,world|0,0,0,world]> as:farmcube
- while <server.flag[index]> != 1:
- flag server index:--
- note remove as:farm_area_<server.flag[index]>
- flag server index:1
- flag server cuboids:!
- narrate "farms reset"
if <context.args.get[1]> == mayor:
- remove <player.flag[has_mayor]>
- narrate "mayor removed"
- flag player has_mayor:!