Date: 2020/11/07 05:58:33 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
world:
type: world
events:
on player right clicks end_portal_frame:
# If player has ships
- if <player.has_flag[ships]>:
# Test if ship is player's
- define counter 1
- define blShip false
- foreach <player.flag[ships]>:
# Tests if ship in dock is player's ship.
- if <script[<[value]>].data_key[location]> == <context.location>:
- flag player nShipId:<[counter]>
- define blShip true
- define counter:++
- if <[blShip]>:
- repeat 28:
- define controllist:->:i@air
- define controllist[11]:i@stone_button[display_name=Hyperdrive]
- define "controllist[12]:i@stone_button[display_name=Sublight Drive]"
- define "controllist[13]:i@stone_button[display_name=Landing Jets]"
- define "controllist[17]:i@map[display_name=Navigation Computer]"
- note "<inventory[generic[title=Flight Control;size=45;contents=<[controllist]>]]>" as:flight_control
- inventory open d:flight_control
#- else:
#- narrate "Access Denied"
on player clicks in flight_control:
- define ship <player.flag[ships].get[<player.flag[nShipId]>]>
- define model <script[<[ship]>].data_key[model]>
- define location <script[<[ship]>].data_key[location]>
- define dock <script[<[ship]>].data_key[dock]>
- define worldName <location[<[location]>].world.name>
# Hyperdrive
- if <context.item> == "i@stone_button[display_name=Hyperdrive]":
- if <[worldName]> == "Space":
- if <player.has_flag[destination]>:
- inventory close d:flight_control
- narrate "Engaging Hyperdrive engine..."
- wait 1
- define xneg <util.random.int[1].to[2]>
- define yneg <util.random.int[1].to[2]>
- define xloc <util.random.int[60].to[100]>
- define yloc <util.random.int[60].to[100]>
- if <[xneg]> == 1:
- define xloc:*:-1
- if <[yneg]> == 1:
- define yloc:*:-1
- define planetaryOffset <location[<script[<player.flag[destination]>].data_key[center]>].add[<[xloc]>,0,<[yloc]>]>
- cast blindness duration:2
- cast slow duration:2 amplifier:10
- wait 1
- playeffect effect:FIREWORKS_SPARK at:<player.location> visibility:100 quantity:500 data:0.5 offset:0.8
- ^schematic load name:<[model]>
- ~schematic paste name:<[model]> <[planetaryOffset]> noair
- ^schematic unload name:<[model]>
- teleport <player> <[planetaryOffset].add[0,0,-2]>
- ^schematic load name:<[model]>_blank
- ^schematic paste name:<[model]>_blank <[location]>
- ^schematic unload name:<[model]>_blank
- narrate "We have arrived at <player.flag[destination]>."
- ~yaml load:scripts/_ships_player.yml id:fileShips
- yaml id:fileShips set <[ship]>.location:<[location]>
- ~yaml savefile:scripts/_ships_player.yml id:fileShips
- yaml unload id:fileShips
- flag player destination:!
- flag player nShipId:!
- else:
- narrate "Destination not set."
- else:
- narrate "You must exit the planet's gravitational field to activate the Hyperdrive engine."
# Sublight Drive
- else if <context.item> == "i@stone_button[display_name=Sublight Drive]":
# Test if trying to enter a world
- if <[worldName]> == "Space":
# Count vacant hangars
- define counterreg 1
- define nHangarId 0
- define blFirst true
- foreach <server.flag[<script[<[dock]>_hangars]>]>:
- if <[value]> == "vacant":
- if <[blFirst]> == "true":
- define nHangarId <[counterreg]>
- define blFirst false
- define counterreg:++
# If no vacant hangars
- if <[blFirst]> == "true":
- random:
- chat "There aren't any hangars available at the moment I'm afraid."
- chat "I'm sorry, they're all occupied currently."
- chat "You'll have to wait for one to become available."
# Else if hangars are vacant
- else:
# Define location as the center of the hangar plus the ship navigation offset
- define hangarOffest <location[<script[<[dock]>_hangar_<[nHangarId]>].data_key[center]>].add[<script[<[model]>_data].data_key[offsetX]>,<script[<[model]>_data].data_key[offsetY]>,<script[<[model]>_data].data_key[offsetZ]>]>
- ^schematic load name:<[model]>
- ~schematic paste name:<[model]> <[hangarOffest].add[0,50,0]> noair
- ^schematic unload name:<[model]>
- teleport <player> <[hangarOffest].add[0,50,-2]>
- ^schematic load name:<[model]>_blank
- ^schematic paste name:<[model]>_blank <[location]>
- ^schematic unload name:<[model]>_blank
- ~yaml load:scripts/_ships_player.yml id:fileShips
- yaml id:fileShips set <[ship]>.location:<[hangarOffest]>
- ~yaml savefile:scripts/_ships_player.yml id:fileShips
- yaml unload id:fileShips
- flag server <location[<[hangarOffest]>].world.name>_hangars[<[nHangarId]>]:<[ship]>
- execute as_server "dmarker update id:<script[<location[<[hangarOffest]>].world.name>_hangar_<[nHangarId]>].data_key[marker]> icon:yellowflag"
# Else if trying to enter space
- else:
# If ship is not docked
- if <location[<[dock]>].add[<script[<[model]>_data].data_key[offsetX]>,<script[<[model]>_data].data_key[offsetY]>,<script[<[model]>_data].data_key[offsetZ]>]> != <[location]>:
- define xneg <util.random.int[1].to[2]>
- define yneg <util.random.int[1].to[2]>
- define xloc <util.random.int[60].to[100]>
- define yloc <util.random.int[60].to[100]>
- if <[xneg]> == 1:
- define xloc:*:-1
- if <[yneg]> == 1:
- define yloc:*:-1
- define planetaryOffset <location[<script[<[worldName]>].data_key[center]>].add[<[xloc]>,0,<[yloc]>]>
- ^schematic load name:<[model]>
- ~schematic paste name:<[model]> <[planetaryOffset].add[0,50,0]> noair
- ^schematic unload name:<[model]>
- teleport <player> <[planetaryOffset].add[0,50,-2]>
- ^schematic load name:<[model]>_blank
- ^schematic paste name:<[model]>_blank <[location]>
- ^schematic unload name:<[model]>_blank
- define counterreg 1
# Update server flags to say hangar now vacant
- foreach <server.flag[<[worldName]>_hangars]>:
- if <[value]> == <[ship]>:
- flag server <[worldName]>_hangars[<[counterreg]>]:vacant
- execute as_server "dmarker update id:<script[<[worldName]>_hangar_<[counterreg]>].data_key[marker]> icon:greenflag"
- define counterreg:++
- ~yaml load:scripts/_ships_player.yml id:fileShips
- yaml id:fileShips set <[ship]>.location:<[planetaryOffset]>
- yaml id:fileShips set <[ship]>.dock:<[planetaryOffset].world.name>
- ~yaml savefile:scripts/_ships_player.yml id:fileShips
- yaml unload id:fileShips
# Else if ship is docked
- else:
- narrate "Sublight Drive can't be activated while docked."
# Landing Jets
- else if <context.item> == "i@stone_button[display_name=Landing Jets]":
- if <[worldName]> != "Space":
- if <location[<[dock]>].add[<script[<[model]>_data].data_key[offsetX]>,<script[<[model]>_data].data_key[offsetY]>,<script[<[model]>_data].data_key[offsetZ]>]> == <[location]>:
- ^schematic load name:<[model]>
- ~schematic paste name:<[model]> <location[<[location]>].add[0,50,0]> noair
- ^schematic unload name:<[model]>
- teleport <player> <location[<[location]>].add[0,50,-2]>
- ^schematic load name:<[model]>_blank
- ^schematic paste name:<[model]>_blank <[location]>
- ^schematic unload name:<[model]>_blank
- ~yaml load:scripts/_ships_player.yml id:fileShips
- yaml id:fileShips set <[ship]>.location:<location[<[location]>].add[0,50,0]>
- ~yaml savefile:scripts/_ships_player.yml id:fileShips
- yaml unload id:fileShips
- narrate "Dock cleared."
- else:
- ^schematic load name:<[model]>
- ~schematic paste name:<[model]> <location[<[location]>].add[0,-50,0]> noair
- ^schematic unload name:<[model]>
- teleport <player> <location[<[location]>].add[0,-50,-2]>
- ^schematic load name:<[model]>_blank
- ^schematic paste name:<[model]>_blank <[location]>
- ^schematic unload name:<[model]>_blank
- ~yaml load:scripts/_ships_player.yml id:fileShips
- yaml id:fileShips set <[ship]>.location:<location[<[location]>].add[0,-50,0]>
- ~yaml savefile:scripts/_ships_player.yml id:fileShips
- yaml unload id:fileShips
- narrate "Docked."
- else:
- narrate "Landing jets are of little use in Space!."
# Navigation Computer
- else if <context.item> == "i@map[display_name=Navigation Computer]":
- inventory close d:flight_control
- narrate "Loading navigational maps..."
# Max 15
- if <location[<script[<player.flag[ships].get[<player.flag[nShipId]>]>].data_key[location]>].world.name> != "Space":
- define gridX <script[<location[<script[<player.flag[ships].get[<player.flag[nShipId]>]>].data_key[location]>].world.name>].data_key[gridX]>
- else:
- define gridX <script[<script[<player.flag[ships].get[<player.flag[nShipId]>]>].data_key[dock]>].data_key[gridX]>
- define gridX:-:4
- if <[gridX]> < 1:
- define gridX 1
- if <[gridX]> > 15:
- define gridX 15
# Max 16
- if <location[<script[<player.flag[ships].get[<player.flag[nShipId]>]>].data_key[location]>].world.name> != "Space":
- define gridY <script[<location[<script[<player.flag[ships].get[<player.flag[nShipId]>]>].data_key[location]>].world.name>].data_key[gridY]>
- else:
- define gridY <script[<script[<player.flag[ships].get[<player.flag[nShipId]>]>].data_key[dock]>].data_key[gridY]>
- define gridY:-:3
- if <[gridY]> < 1:
- define gridY 1
- if <[gridY]> > 16:
- define gridY 16
- flag player counterY:<[gridY]>
- repeat 6:
- flag player counterX:<[gridX]>
- repeat 9:
- flag player maplist:->:<script[space].data_key[grid].get[<player.flag[counterY]>].get[<player.flag[counterX]>]>
- flag player counterX:++
- flag player counterY:++
- note <inventory[generic[title=Navigation;size=54;contents=<player.flag[maplist]>]]> as:mapinv
- inventory open d:mapinv
- flag player counterX:!
- flag player counterY:!
- flag player maplist:!
- determine cancelled
on player clicks void|point in inventory:
- narrate "Destination set: <context.item.lore.get[1]>"
- flag player destination:<context.item.lore.get[1]>
- inventory close d:<context.clicked_inventory>
- inventory open d:flight_control
- determine cancelled
#on player death:
#- if <player.has_flag[hangars]>:
# - foreach <player.flag[hangars]>:
# # remove associated astromech
# - define sublist <server.flag[hangars].get[<[value]>]>
# - remove <def[sublist].get[1]>
# # set global hangar flag to vacant
# - flag server hangars[<[value]>]:vacant
# # remove hangar flag from player
# - flag player hangars:!
on entity targets player:
- if <player.has_flag[sith]>:
- if <context.entity.name> == skeleton || <context.entity.name> == wither_skeleton || <context.entity.name> == stray || <context.entity.name> == zombie || <context.entity.name> == husk || <context.entity.name> == drowned:
- determine cancelled
- else:
- attack <context.entity.location.find.entities[skeleton].within[20]> target:<context.entity>
- attack <context.entity.location.find.entities[wither_skeleton].within[20]> target:<context.entity>
- attack <context.entity.location.find.entities[stray].within[20]> target:<context.entity>
- attack <context.entity.location.find.entities[zombie].within[20]> target:<context.entity>
- attack <context.entity.location.find.entities[husk].within[20]> target:<context.entity>
- attack <context.entity.location.find.entities[drowned].within[20]> target:<context.entity>
on entity damages player:
- if <player.has_flag[sith]>:
- attack <context.entity.location.find.entities[skeleton].within[20]> target:<context.entity>
- attack <context.entity.location.find.entities[wither_skeleton].within[20]> target:<context.entity>
- attack <context.entity.location.find.entities[stray].within[20]> target:<context.entity>
- attack <context.entity.location.find.entities[zombie].within[20]> target:<context.entity>
- attack <context.entity.location.find.entities[husk].within[20]> target:<context.entity>
- attack <context.entity.location.find.entities[drowned].within[20]> target:<context.entity>