Paste #9273: Untitled Paste

Date: 2014/09/04 12:10:21 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714


"conquererevents":
    type: world
    debug: false
    events:
      on player damages npc:
      - if li@102|119|165|196|74|226|244 !contains <context.entity.as_npc.id> queue clear
      - if <server.has_flag[<context.entity.as_npc.id>cooldown]> queue clear
      - flag server <context.entity.as_npc.id>cooldown duration:25s
      - if <el@val[<player.faction>].strip_colors> == faction@wilderness { 
        - announce "<&c><&lb><&4>Towns<&c><&rb> <&c>The King of <el@val[<location[<player.location>].faction.name>].strip_colors> is being attacked by a factionless player!"
        } else {
        - announce "<&c><&lb><&4>Towns<&c><&rb> <&c>The faction <el@val[<player.faction.name>].strip_colors> is attacking the king of <el@val[<location[<player.location>].faction.name>].strip_colors>!"
        }
      - ^foreach <server.list_online_players> {
        - ^playsound <%value%> sound:irongolem_death pitch:1.5
        - ^playsound <%value%> sound:irongolem_death pitch:0.5
        }
      on player kills npc:
      - if li@102|119|165|196|74|226|244 !contains <context.entity.as_npc.id> queue clear
      - if <npc.health||0> != 0 queue clear
      - run startconquering as:<context.damager> def:<context.damager>|<context.entity>
      on player death:
      - flag <player> deathfactioncaptureCD duration:195s
      - run capturecooldowndelay as:<player>
      on server start:
      - run conquererrewardloop
      - run conquererscoreboard
      - foreach <global.flag[factionsbeingcaptured].as_list> {
        - flag server capping%value%:!
        }
      - flag server factionsbeingcaptured:!

"capturecooldowndelay":
    type: task
    debug: false
    script:
    - wait 190s
    - if <global.flag[capping<el@val[<location[<player.location>].faction>].strip_colors>]> != <el@val[<player.faction>].strip_colors> queue clear
    - if <player.flag[deathfactioncaptureCD].expiration.in_seconds> > 6 queue clear
    - narrate "<&c><&lb><&4>Towns<&c><&rb> <&a>Your capturing cooldown expired!"
    - playsound <player> sound:successful_hit pitch:0.5
    - wait 10t
    - playsound <player> sound:successful_hit pitch:0.5
    - wait 10t
    - playsound <player> sound:successful_hit pitch:0.5

"startconquering":
    type: task
    debug: false
    script:
    - ^define faction <el@val[<location[<%1%.location>].faction>].strip_colors>
    - if <global.flag[%faction%capturedby]> == <el@val[<player[%1%].faction>].strip_colors> {
      - narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>You have killed your own king!"
      - wait 3
      - ^execute as_server "npc spawn <%2%.replace[n@]>"
      - queue clear
      }
    - if <el@val[<player.faction>].strip_colors> == faction@wilderness {
      - narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>You must be in a faction to capture towns!"       
      - wait 3
      - ^execute as_server "npc spawn <%2%.replace[n@]>"
      - queue clear
      }
    - if <player.has_flag[MarkedCriminal]> {
      - narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>Criminals cannot capture a town!"
      - wait 3
      - ^execute as_server "npc spawn <%2%.replace[n@]>"
      - queue clear
      }
    - ^if <%1%.has_flag[deathfactioncaptureCD]> {
      - narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>You've recently been slain and can't capture towns for another <player.flag[deathfactioncaptureCD].expiration.formatted>."
      - wait 3
      - ^execute as_server "npc spawn <%2%.replace[n@]>"
      - queue clear
      }
    - ^if <global.flag[factionsbeingcaptured].as_list> contains %faction% {
      - if <el@val[<player[%1%].faction>].strip_colors> == <server.flag[capping%faction%]> {
        - narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>Your faction is already capturing <%faction%.name>!"
        } else {
        - narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>This town is already being captured! Kill the opposing players first!"
        - queue clear
        }
      } else {
      - ^flag server factionsbeingcaptured:->:%faction%
      - ^flag server capping%faction%:<el@val[<player[%1%].faction>].strip_colors>
      - ^flag server showbossbar:%3% duration:5s
      - ^flag server %faction%count duration:1h
      - announce "<&c><&lb><&4>Towns<&c><&rb> <&c><%1%.name> from <el@val[<player[%1%].faction.name>].strip_colors> started capturing <%faction%.name>!"
      - wait 1
      - announce "<&c><&lb><&4>Towns<&c><&rb> <&c><el@val[<player[%1%].faction.name>].strip_colors> will capture <%faction%.name> in 1 hour if not defended!"
      - narrate "<&c><&lb><&4>Towns<&c><&rb> <&a>You've started capturing <%faction%.name>. You or your faction must hold it for 1 hour!"
      - foreach <server.list_online_players> {
        - playsound <%value%> sound:wither_death pitch:2.5
        }
      - ^foreach <server.list_npcs> {
        - ^if <%value%.name> contains '<%faction%.name> Guard' {
          - ^execute as_server 'npc select <%value%.id>'
          - execute as_server 'sentry target remove event:PvP'
          }
        }
      - run conquercountdown as:%1% def:%1%|%2%|%faction%|<server.flag[%faction%count].expiration.in_seconds>|<el@val[<player[%1%].faction>].strip_colors>
      }

"conquercountdown":
    type: task
    debug: false
    script:
    - ^if !<server.has_flag[showbossbar]> flag server showbossbar:%3% duration:5s
    - ^flag server %3%capturing:!
    - ^flag server infactiongetting%3%:!
    - ^foreach <server.list_online_players> {
      - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% {
        - ^flag server infactiongetting%3%:->:%value%
        - ^if <el@val[<location[<%value%.location>].faction>].strip_colors> = %3% {
          - if !<%value%.has_flag[deathfactioncaptureCD]> flag server %3%capturing:->:%value%
          }
        }
      }
    - ^if <global.flag[%3%capturing].size> < 1 {
      - ^flag server showbossbar:%3% duration:5s
      - narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>Your faction will lose the battle for <%3%.name> in 30 seconds if no members are present!" targets:<global.flag[infactiongetting%3%].as_list>
      - ^foreach <global.flag[infactiongetting%3%].as_list> {
        - if <%value%.has_flag[deathfactioncaptureCD]> narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>You've recently been slain and can't capture towns for another <player.flag[deathfactioncaptureCD].expiration.formatted>." player:%value%
        }
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[30].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[29].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[28].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[27].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[26].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[25].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[24].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[23].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[22].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[21].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^flag server %3%count duration:%4%s
      - ^flag server %3%capturing:!
      - ^flag server infactiongetting%3%:!
      - ^foreach <server.list_online_players> {
        - ^if <player[%value%].faction> == %5% {
          - ^flag server infactiongetting%3%:->:%value%
          - ^if <el@val[<location[<%value%.location>].faction>].strip_colors> = %3% {
            - if !<%value%.has_flag[deathfactioncaptureCD]> flag server %3%capturing:->:%value%
            }
          }
        }
      }
    - ^if <global.flag[%3%capturing].size> < 1 {
      - ^flag server showbossbar:%3% duration:5s
      - ^narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>Your faction will lose the battle for <%3%.name> in 20 seconds if no members are present!" targets:<global.flag[infactiongetting%3%].as_list>
      - ^foreach <global.flag[infactiongetting%3%].as_list> {
        - if <%value%.has_flag[deathfactioncaptureCD]> narrate "<&c>You've recently been slain and can't capture towns for another <player.flag[deathfactioncaptureCD].expiration.formatted>." player:%value%
        }
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[20].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[19].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[18].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[17].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[16].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[15].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[14].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[13].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[12].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[11].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^flag server %3%count duration:%4%s
      - ^flag server %3%capturing:!
      - ^flag server infactiongetting%3%:!
      - ^foreach <server.list_online_players> {
        - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% {
          - ^flag server infactiongetting%3%:->:%value%
          - ^if <el@val[<location[<%value%.location>].faction>].strip_colors> = %3% {
            - if !<%value%.has_flag[deathfactioncaptureCD]> flag server %3%capturing:->:%value%
            }
          }
        }
      }
    - ^if <global.flag[%3%capturing].size> < 1 {
      - ^flag server showbossbar:%3% duration:5s
      - ^narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>Your faction will lose the battle for <%3%.name> in 10 seconds if no members are present!" targets:<global.flag[infactiongetting%3%].as_list>
      - ^foreach <global.flag[infactiongetting%3%].as_list> {
        - if <%value%.has_flag[deathfactioncaptureCD]> narrate "<&c>You've recently been slain and can't capture towns for another <player.flag[deathfactioncaptureCD].expiration.formatted>." player:%value%
        }
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[10].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[09].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[08].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[07].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[06].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[05].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[04].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[03].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[02].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[01].div[30].mul[200].as_int>|<&a><%5%.name> <&c>is losing the battle for <&6><%3%.name>!'
          - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% playsound <%value%> sound:note_pling pitch:1.5
          }
        }
      - wait 1s
      - ^flag server %3%count duration:%4%s
      - ^flag server %3%capturing:!
      - ^flag server infactiongetting%3%:!
      - ^foreach <server.list_online_players> {
        - ^if <el@val[<player[%value%].faction>].strip_colors> == %5% {
          - ^flag server infactiongetting%3%:->:%value%
          - ^if <el@val[<location[<%value%.location>].faction>].strip_colors> = %3% {
            - if !<%value%.has_flag[deathfactioncaptureCD]> flag server %3%capturing:->:%value%
            }
          }
        }
      }
    - ^if <global.flag[%3%capturing].size> < 1 {
      - ^flag server factionsbeingcaptured:<-:%3%
      - ^flag server capping%3%:!
      - ^execute as_server "npc spawn <%2%.replace[n@]>"
      - ^narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>Your faction has failed to capture <%3%.name>!" targets:targets:<global.flag[infactiongetting%3%].as_list>
      - ^if <server.list_online_players.size> > 0 {
        - ^flag server showbossbar:%3% duration:5s
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:0|<&a><%5%.name> <&c>has lost the battle for <&6><%3%.name>!'
          - playsound <%value%> sound:wither_spawn pitch:2.5
          }
        }
      - announce "<&c><&lb><&4>Towns<&c><&rb> <&c><%5%.name> has lost the battle for <%3%.name>!"
      - ^foreach <server.list_npcs> {
        - ^if <%value%.name> contains '<%3%.name> Guard' {
          - ^execute as_server 'npc select <%value%.id>'
          - execute as_server 'sentry target add event:pvp'
          }
        }
      - wait 10s
      - ^if <server.list_online_players.size> > 0 {
        - ^flag server showbossbar:%3% duration:5s
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% show_boss_bar
          }
        }
      - queue clear
      }
    - ^if <server.list_online_players.size> > 0 {
      - ^foreach <server.list_online_players> {
        - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:<el@val[%4%].div[3600].mul[200].as_int||0>|<&c>The faction <&a><%5%.name> <&c>is capturing <&6><%3%.name>! <&pipe> <&c><d@%4%.in_minutes.as_int> minutes.'
        }
      }
    - if %4% < 1 {
      - ^flag server factionsbeingcaptured:<-:%3%
      - ^flag server %3%capturedby:%5%
      - ^flag server capping%3%:!
      - ^execute as_server "npc spawn <%2%.replace[n@]>"
      - announce "<&c><&lb><&4>Towns<&c><&rb> <&a><%5%.name> has captured <%3%.name>!"
      - ^if <server.list_online_players.size> > 0 {
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% 'show_boss_bar:200|<&a><%5%.name> has captured <&6><%3%.name>!'
          - playsound <%value%> sound:level_up pitch:0.5
          }
        }
      - wait 10s
      - ^if <server.list_online_players.size> > 0 {
        - ^flag server showbossbar:%3% duration:5s
        - ^foreach <server.list_online_players> {
          - ^if <global.flag[showbossbar]||%3%> == %3% adjust %value% show_boss_bar
          }
        }
      } else {
      - run conquercountdown as:%1% def:%1%|%2%|%3%|<server.flag[%3%count].expiration.in_seconds.replace[forever].with[0]||0>|%5% delay:38t
      }

"conquererrewardloop":
    type: task
    debug: false
    script:
    - foreach li@Dykuma|Newfort|Eversong|Icelyn|Loktar|Norpond|Windport {
      - define faction %value%
      - foreach <server.flag[faction@%faction%chests].as_list> {
        - random {
          - inventory add destination:%value% origin:i@DIAMOND slot:<util.random.int[1].to[27]>
          - inventory add destination:%value% origin:i@GOLD_INGOT slot:<util.random.int[1].to[27]>
          - inventory add destination:%value% origin:i@IRON_INGOT slot:<util.random.int[1].to[27]>
          }
        - random {
          - inventory add destination:%value% origin:i@TNT slot:<util.random.int[1].to[27]>
          - inventory add destination:%value% origin:i@exp_bottle  slot:<util.random.int[1].to[27]>
          - inventory add destination:%value% origin:i@GOLDEN_APPLE slot:<util.random.int[1].to[27]>
          }
        - random {
          - inventory add destination:%value% origin:i@TNT slot:<util.random.int[1].to[27]>
          - inventory add destination:%value% origin:i@ENDER_PEARL slot:<util.random.int[1].to[27]>
          - inventory add destination:%value% origin:i@373,16421 slot:<util.random.int[1].to[27]>
          }
        - if <util.random.int[1].to[100]> <= 5 {
          - random {
            - inventory add destination:%value% origin:i@gold_block slot:<util.random.int[1].to[27]>
            - inventory add destination:%value% origin:i@diamond_block slot:<util.random.int[1].to[27]>
            - inventory add destination:%value% origin:i@iron_block slot:<util.random.int[1].to[27]>
            }
          }
        - if <util.random.int[1].to[100]> <= 1 {
          - random {
            - inventory add destination:%value% origin:i@383,50 slot:<util.random.int[1].to[27]>
            - inventory add destination:%value% origin:i@383,61 slot:<util.random.int[1].to[27]>
            - inventory add destination:%value% origin:i@383,51 slot:<util.random.int[1].to[27]>
            - inventory add destination:%value% origin:i@383,92 slot:<util.random.int[1].to[27]>
            - inventory add destination:%value% origin:i@383,90 slot:<util.random.int[1].to[27]>
            - inventory add destination:%value% origin:i@383,52 slot:<util.random.int[1].to[27]>
            }
          }
        }
      - if <server.has_flag[faction@%faction%capturedby]> {
        - flag server givemoney%faction%:!
        - foreach <server.list_online_players> {
          - if <el@val[<player[%value%].faction>].strip_colors> == <global.flag[faction@%faction%capturedby]> {
            - if <global.flag[givemoney%faction%]> != contain %value% flag server givemoney%faction%:->:%value%
            }
          }
        - foreach <global.flag[givemoney%faction%].as_list> {
          - give money qty:<global.flag[givemoney%faction%].size.mul[10].add[250]> player:%value%
          - narrate "<green>Each faction member has been given <dark_purple><global.flag[givemoney%faction%].size.mul[10].add[250].as_int> <green>dollars of which <dark_purple><global.flag[givemoney%faction%].size.mul[10].as_int> <green>is bonus for each member for holding <dark_purple>%faction%." player:%value%
          }
        }
      }
    - flag server capreward duration:15m
    - run conquererrewardloop delay:15m

"conquerercaplist":
    type: world
    debug: false
    events:
      on towns command:
      - if <context.args.get[1]> == status {
        - if li@Dykuma|Newfort|Eversong|Icelyn|Loktar|Norpond|Windport contains <context.args.get[2]> {
            - if <global.flag[factionsbeingcaptured].as_list> contains faction@<context.args.get[2]> {
              - narrate "<&e><<global.flag[faction@<context.args.get[2]>capturedby]>.name||No one><&6> currently has <context.args.get[2]>. <&c>(Getting captured by<&co> <&e><<global.flag[cappingfaction@<context.args.get[2]>]>.name><&c>)"
              } else {
              - narrate "<&e><<global.flag[faction@<context.args.get[2]>capturedby]>.name||No one><&6> currently has <context.args.get[2]>."
              }
          } else {
          - foreach li@Dykuma|Newfort|Eversong|Icelyn|Loktar|Norpond|Windport {
            - if <global.flag[factionsbeingcaptured].as_list> contains faction@%value% {
              - narrate "<&6>%value%<&co> <&e><<global.flag[faction@%value%capturedby]>.name||No one> <&c>(being captured by<&co> <&e><<global.flag[cappingfaction@%value%]>.name><&c>)"
              } else {
              - narrate "<&6>%value%<&co> <&e><<global.flag[faction@%value%capturedby]>.name||No one>"
              }
            }
          }
        } else if <context.args.get[1]> == edit {
        - if !<player.is_op> queue clear
        - if li@Dykuma|Newfort|Eversong|Icelyn|Loktar|Norpond|Windport contains <context.args.get[2]> {
          - if <context.args.size> == 3 {
            - narrate "<&c>You have set the owner of <context.args.get[2]> to <context.args.get[3]>."
            - flag server 'faction@<context.args.get[2]>capturedby:faction@<context.args.get[3]>'           
            } else {
            - narrate "<&c>Invalid arguments! /towns edit townname factionname"
            }
          } else {
          - narrate "<&c>This is not an existing capturable town."
          }
        } else if <context.args.get[1]> == score {
        - run conquererscoreboardtask instantly
        } else {
        - narrate "<&c>/towns [status] (town)"
        - if <player.is_op> narrate "<&c>/towns [edit] (town) (faction)"
        }
      - determine fulfilled

"conquererscoreboardtask":
    type: task
    debug: false
    script:
    - ^scoreboard add viewers:<player> id:FJRHJSKHKJDH
    - ^if li@Dykuma|Newfort|Eversong|Icelyn|Loktar|Norpond|Windport !contains <el@val[<location[<player.location>].faction.name>].strip_colors> queue clear
    - ^define faction <el@val[<location[<player.location>].faction.name>].strip_colors>
    - scoreboard remove id:%faction%<player.name>
    - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&4><&4>------------' score:15
    - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&6>Holder<&co>' score:14
    - ^if <el@val[<player.faction>].strip_colors> == <global.flag[faction@%faction%capturedby]> scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&a><el@val[<<global.flag[faction@%faction%capturedby]>.name||<&e>None>].substring[1,16]>' score:13
    - ^if <el@val[<player.faction>].strip_colors> != <global.flag[faction@%faction%capturedby]> scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&c><el@val[<<global.flag[faction@%faction%capturedby]>.name||<&e>None>].substring[1,16]>' score:13
    - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&b><&4>------------' score:12
    - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&6>Attacker<&co>' score:11
    - ^if <el@val[<player.faction>].strip_colors> == <global.flag[cappingfaction@%faction%]> scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&a><el@val[<<global.flag[cappingfaction@%faction%]>.name||<&a>None>].substring[1,16]>' score:10
    - ^if <el@val[<player.faction>].strip_colors> != <global.flag[cappingfaction@%faction%]> scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&c><el@val[<<global.flag[cappingfaction@%faction%]>.name||<&e>None>].substring[1,16]>' score:10
    - ^if <server.flag[factionsbeingcaptured].as_list> contains faction@%faction% {
      - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&4>------------' score:9
      - ^if <el@val[<player.faction>].strip_colors> == <global.flag[cappingfaction@%faction%]> {
        - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&6>victory in<&co>' score:8
        } else if <el@val[<player.faction>].strip_colors> == <global.flag[faction@%faction%capturedby]> {
        - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&6>Defeat in<&co>' score:8
        } else {
        - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&6>Captured in<&co>' score:8
        }
      - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&e><server.flag[faction@%faction%count].expiration.formatted||N/A>' score:7
      }
    - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&a><&4>------------' score:6
    - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&6>Guards<&co>' score:5
    - ^if <server.flag[factionsbeingcaptured].as_list> !contains faction@%faction% scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&a>Active' score:4
    - ^if <server.flag[factionsbeingcaptured].as_list> contains faction@%faction% scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&c>Inactive' score:4
    - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&e><&4>------------' score:3
    - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&6>Next reward<&co>' score:2
    - ^scoreboard add id:%faction%<player.name> obj:<&6>%faction% 'lines:<&e><global.flag[capreward].expiration.formatted.replace[Forever].with[<&a>Now!]||<&a>Now!>' score:1
    - ^scoreboard add viewers:<player> id:%faction%<player.name>
    - run scoreboardremove delay:5s
"scoreboardremove":
    type: task
    debug: false
    script:
    - ^scoreboard add viewers:<player> id:FJRHJSKHKJDH

"conquererchestopening":
    type: world
    debug: false
    events:
      on player opens inventory:
      - if <server.flag[<el@val[<location[<player.location>].faction>].strip_colors>chests].as_list> !contains <context.inventory.location||0> queue clear
      - if <player.faction> == <global.flag[<el@val[<location[<player.location>].faction>].strip_colors>capturedby]> {
        - narrate "<&c><&lb><&4>Towns<&c><&rb> <&a>You open a reward chest. Only faction members and Outlaws can open this chest."
        - narrate "<&c><&lb><&4>Towns<&c><&rb> <&a>Check this chest every 15 minutes for more rewards."
        } else if <global.flag[AssassinGuildMembers].as_list> contains <player.name> {
        - narrate "<&c><&lb><&4>Towns<&c><&rb> <&6>As a member of the Outlaws Guild, you are able to pick the lock."
        } else if <player.is_op> {
        - narrate "<&c>Permissions Override. Letting you access reward chest."
        } else {
        - narrate "<&c><&lb><&4>Towns<&c><&rb> <&4>This chest is locked. You must take over the town or join the Outlaws Guild to unlock."
        - determine cancelled
        }

"conquererchestmanager":
    type: world
    debug: false
    events:
      on conqchest command:
      - if !<player.is_op> queue clear
      - if <context.args.get[1]> == add {
        - if <player.location.cursor_on.material> == m@chest {
          - if <global.flag[<el@val[<location[<player.location>].faction>].strip_colors>chests]> !contains <player.location.cursor_on> {
            - flag server <el@val[<location[<player.location>].faction>].strip_colors>chests:->:<player.location.cursor_on>
            - narrate "<&a>You've added this chest to <el@val[<location[<player.location>].faction.name>].strip_colors>'s reward chests."
            } else {
            - narrate "<&c>This is already a reward chest for <el@val[<location[<player.location>].faction.name>].strip_colors>."
            }
          } else {
          - narrate "<&c>This is not a chest."
          }
        }
      - if <context.args.get[1]> == delete {
        - if <player.location.cursor_on.material> == m@chest {
          - if <global.flag[<el@val[<location[<player.location>].faction>].strip_colors>chests]> contains <player.location.cursor_on> {
            - flag server <el@val[<location[<player.location>].faction>].strip_colors>chests:<-:<player.location.cursor_on>
            - narrate "<&a>You removed this chest from <el@val[<location[<player.location>].faction.name>].strip_colors>'s reward chests."
            } else {
            - narrate "<&c>This is not a reward chest for <el@val[<location[<player.location>].faction.name>].strip_colors>."
            }
          } else {
          - narrate "<&c>This is not a chest."
          }
        }
      - if <context.args.get[1]> == check {
        - if <player.location.cursor_on.material> == m@chest {
          - if <global.flag[<el@val[<location[<player.location>].faction>].strip_colors>chests]> contains <player.location.cursor_on> {
            - narrate "<&a>This is a reward chest for <el@val[<location[<player.location>].faction.name>].strip_colors>."
            } else {
            - narrate "<&c>This is not a reward chest for <el@val[<location[<player.location>].faction.name>].strip_colors>."
            }
          } else {
          - narrate "<&c>This is not a chest."
          }
        }
      - if <context.args.get[1]> == list {
        - if <server.has_flag[<el@val[<location[<player.location>].faction>].strip_colors>chests]> {
          - narrate "<&a>All reward chests in <el@val[<location[<player.location>].faction.name>].strip_colors><&co>"
          - narrate "<&a><server.flag[<el@val[<location[<player.location>].faction>].strip_colors>chests].as_list.formatted>"
          } else {
          - narrate "<&c>Not in a town containing reward chests."
          }
        }
      - if <context.args.get[1]> == help || <context.args.size> < 1 {
        - narrate "<&c>/conqchest [Add / Delete / Check / List / Clear] [Towns / All]"
        }
      - if <context.args.get[1]> == clear {
        - if <context.args.get[2]> == town {
          - foreach  <global.flag[<el@val[<location[<player.location>].faction>].strip_colors>chests].as_list> {
            - inventory clear destination:<%value%.inventory>
            }
          - narrate "<&6>All reward chests in <<el@val[<location[<player.location>].faction>].strip_colors>.name>  have been cleared"
          } else if <context.args.get[2]> == all {
          - foreach li@Dykuma|Newfort|Eversong|Icelyn|Loktar|Norpond|Windport {
            - foreach <global.flag[faction@%value%chests].as_list> {
              - inventory clear destination:<%value%.inventory>
              }
            }
          - narrate "<&6>All reward chests on this server have been cleared."
          } else {
          - if <global.flag[<el@val[<location[<player.location>].faction>].strip_colors>chests]>contains <player.location.cursor_on> {
            - narrate "<&6>You cleared this reward chest."
            - inventory clear destination:<player.location.cursor_on.inventory>
            } else {
            - narrate "<&c>This is not a reward chest for <<el@val[<location[<player.location>].faction.name>].strip_colors>.name> ."
            }      
          }
        }
      - determine fulfilled
"AntiKite":
    type: world
    debug: false
    events:
      on player damages npc:
      - if <context.entity.as_npc.name.contains[king]> {
        - ^flag <player> DamagedNPCRecently duration:30s
        }
      on player walks over notable:
      - ^if <player.has_flag[DamagedNPCRecently]> && li@l@AntiKiteDykuma|l@AntiKiteDykuma2|l@AntiKiteDykuma3 contains <context.notable> {
        - ^narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>You have engaged the king and cannot leave this building!"
        - ^teleport <player> l@-2835,90,2930,world
        - determine fulfilled
        }
      - ^if <player.has_flag[DamagedNPCRecently]> && li@l@AntiKiteNewfort|l@AntiKiteNewfort2|l@AntiKiteNewfort3 contains <context.notable> {
        - ^narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>You have engaged the king and cannot leave this building!"
        - ^teleport <player> l@3555,69,3622,world
        - determine fulfilled
        }
      - ^if <player.has_flag[DamagedNPCRecently]> && li@l@AntiKiteEversong|l@AntiKiteEversong2|l@AntiKiteEversong3 contains <context.notable> {
        - ^narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>You have engaged the king and cannot leave this building!"
        - ^teleport <player> l@-2867,72,-3148,world
        - determine fulfilled
        }
      - ^if <player.has_flag[DamagedNPCRecently]> && li@l@AntiKiteIcelyn|l@AntiKiteIcelyn2|l@AntiKiteIcelyn3 contains <context.notable> {
        - ^narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>You have engaged the king and cannot leave this building!"
        - ^teleport <player> l@3310,70,-3174,world
        - determine fulfilled
        }
      - ^if <player.has_flag[DamagedNPCRecently]> && li@l@AntiKiteLoktar|l@AntiKiteLoktar2|l@AntiKiteLoktar3 contains <context.notable> {
        - ^narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>You have engaged the king and cannot leave this building!"
        - ^teleport <player> l@-4096,65,3154,world
        - determine fulfilled
        }
      - ^if <player.has_flag[DamagedNPCRecently]> && li@l@AntiKiteNorpond|l@AntiKiteNorpond2|l@AntiKiteNorpond3 contains <context.notable> {
        - ^narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>You have engaged the king and cannot leave this building!"
        - ^teleport <player> l@1552,63,-1183,world
        - determine fulfilled
        }
      - ^if <player.has_flag[DamagedNPCRecently]> && li@l@AntiKiteWindport|l@AntiKiteWindport2|l@AntiKiteWindport3 contains <context.notable> {
        - ^narrate "<&c><&lb><&4>Towns<&c><&rb> <&c>You have engaged the king and cannot leave this building!"
        - ^teleport <player> l@-35,63,4320,world
        - determine fulfilled
        }