Paste #123074: Forcepowers

Date: 2024/05/25 10:10:15 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


force_powers:
    type: item
    material: nether_star
    display name: <&b><bold>Force

give_forcepowers:
    type: command
    name: giveforce
    description: Gives you forcepowers
    usage: /giveforce [player]
    script:
    - if !<context.args.is_empty>:
        - define playerName <context.args.get[1]>
        - define playerToGive <server.match_player[<[playerName]>].if_null[null]>
        - if <[playerToGive]> == null:
            - narrate "<&[error]>Can't find player by name '<&[emphasis]><[playerName]><&[error]>'!"
            - stop
        - if !<[playerToGive].inventory.contains_item[force_powers]>:
            - give force_powers player:<[playerToGive]>
        - else:
            - narrate "<&[error]>They already have force powers!"
        - stop
    - if !<player.inventory.contains_item[force_powers]>:
        - give force_powers
    - else:
        - narrate "<&[error]>You already have force powers!"

switch_inventory_script:
    type: task
    script:
    - define target <player[def_target]||<player>>
    #if they have the backpack opened
    - if <[target].has_flag[force_inv_open]>:
      #the contents to set here would be the original contents you stored to the noted backpack inventory's flag
      - define contents_to_set <inventory[forcepowers_inv_<[target].uuid>].flag[original_contents]>
      #note the player's inventory as a backpack inventory (as it has all the contents of it, you can just list them when they're opening the backpack (see ln. 26))
      - note <[target].inventory> as:forcepowers_inv_<[target].uuid>
      #unflag them
      - flag <[target]> force_inv_open:!
      - narrate "Switched back to your normal inventory."
    - else:
      #note a backpack inventory if a note doesn't already exist
      - note <inventory[forcepowers_inventory]> as:forcepowers_inv_<[target].uuid> if:!<inventory[forcepowers_inv_<[target].uuid>].exists>
      #store the inventory contents of the player inventory to the note's flag (see ln. 13)
      - flag <inventory[forcepowers_inv_<[target].uuid>]> original_contents:<[target].inventory.list_contents>
      #the contents to set here would be the noted backpack inventory's contents
      - define contents_to_set <inventory[forcepowers_inv_<[target].uuid>].list_contents.first[36]>
      #flag them
      - flag <[target]> force_inv_open
      - narrate "Switched to your force inventory"

    #save the (changed) netherstar that they use to switch
    - define old_slot_force <[target].item_in_hand>
    #clear the player's inventory and set your predefined contents
    - inventory set o:<item[air].repeat_as_list[36]> slot:1
    - inventory set o:<[contents_to_set]> slot:1

    #change their forcepower item with the changed force power item
    - if <[target].inventory.find_item[force_powers]> > 0:
        - inventory set o:<[old_slot_force]> slot:<[target].inventory.find_item[force_powers]>
        - adjust <[target]> item_slot:<[target].inventory.find_item[force_powers]>
    - else:
        - inventory set o:<[old_slot_force]> slot:1

forcepower_input_script:
    type: world
    events:
        on player right clicks block with:*_spawn_egg flagged:force_inv_open:
            - determine cancelled

        on player right clicks block with:force_powers:
            - ratelimit <player> 1t
            - if !<context.location.exists>:
                - run switch_inventory_script
                - stop
            - if <context.location.block.material.is_interactable> && <context.location.block.material> not matches <list[pumpkin|*_fence|tnt|flower_pot|composter|beehive|bee_nest|*cauldron|]>:
                - stop
            - run switch_inventory_script
        on player right clicks player with:force_powers:
            - ratelimit <player> 1t
            - run switch_inventory_script

        on player drops force_powers:
            - determine cancelled
        on player picks up item flagged:force_inv_open:
            - determine cancelled
        on player drops item flagged:force_inv_open:
            - determine cancelled
        on player left clicks block with:force_powers:
            - if <context.click_type> == DROP:
                - narrate 3000202
                - stop
            - narrate 2
            - if <player.has_flag[equipped_force]>:
                - run <script[<player.flag[equipped_force]>]>
            - else:
                - narrate "<&3><bold>- Select a Force Power before casting!"
            - determine cancelled
        on player damages entity with:force_powers:
            - if <player.has_flag[equipped_force]>:
                - run <script[<player.flag[equipped_force]>]>
            - else:
                - narrate "<&3><bold>- Select a Force Power before casting!"
            - determine cancelled
        on player damages block with:force_powers:
            - if <player.has_flag[equipped_force]>:
                - run <script[<player.flag[equipped_force]>]>
            - else:
                - narrate "<&3><bold>- Select a Force Power before casting!"
            - determine cancelled
        after player inventory slot changes flagged:force_inv_open:
            - if <context.new_item.material> == <material[nether_star]>:
                - if <context.slot> > 9:
                    - if <player.inventory.first_empty> < 1 || <player.inventory.first_empty> > 9:
                        - if <player.inventory.first_empty> < 37:
                            - define slot1_item <player.inventory.slot[1]>
                            - inventory set origin:<context.new_item> slot:1
                            - inventory set origin:<[slot1_item]> slot:<player.inventory.first_empty>
                        - else:
                            - narrate "<&[error]>You seem to have encountered a bug. Please contact an administrator!  ERROR CODE: 0002"
                            - stop
                    - else:
                        - inventory set origin:<context.new_item> slot:<player.inventory.first_empty>
                        - inventory set origin:<item[air]> slot:<context.slot>
                - adjust <player> item_slot:<player.inventory.find_item[force_powers]>
        on player clicks in inventory flagged:force_inv_open:
            - if <context.slot> matches <list[37|38|39|40|41]>:
                - determine cancelled

        on player swaps items offhand:force_powers flagged:force_inv_open:
            - determine cancelled
        on player swaps items flagged:force_inv_open:
            - determine cancelled
        after player scrolls their hotbar flagged:force_inv_open:
            - define force_power force_<player.inventory.slot[<context.new_slot>].display.strip_color.to_lowercase||force>
            - define force_power_slot <player.inventory.find_item[force_powers]>
            - narrate <[force_power_slot]>
            - if <[force_power]> == force_force || <player.inventory.slot[<context.new_slot>].material> == <material[nether_star]>:
                - adjust <player> item_slot:<[force_power_slot]>
                - stop
            - flag <player> equipped_force:<[force_power]>
            - narrate <[force_power]>
            - narrate <[force_power_slot]>
            - inventory adjust slot:<[force_power_slot]> "display:<&b><bold>Force <&f>[<player.inventory.slot[<context.new_slot>].display><&f>]"
            - adjust <player> item_slot:<[force_power_slot]>


force_push:
    type: task
    script:
        - define target <player.eye_location.ray_trace_target[ignore=<player>;range=<script[item_force_push].flag[variables.base_range]>;raysize=0.35]||null>
        - if <[target]> != null && (<[target].is_player> || <[target].is_mob> || <[target].is_npc>):
          - ratelimit <player> <script[item_force_push].flag[variables.base_cooldown]>
          - itemcooldown <item[item_force_push].material> duration:<script[item_force_push].flag[variables.base_cooldown]>
          - push <[target]> origin:<[target].location> destination:<[target].location.with_pose[<player>].forward[<script[item_force_push].flag[variables.base_strength]>]> no_rotate speed:<script[item_force_push].flag[variables.base_strength].mul[0.18]> duration:<script[item_force_push].flag[variables.base_duration]>
          - flag <player> player.force.statistics.cast_push:++

force_pull:
    type: task
    script:
        - define target <player.eye_location.ray_trace_target[ignore=<player>;range=<script[item_force_pull].flag[variables.base_range]>;raysize=0.35]||null>
        - if <[target]> != null && (<[target].is_player> || <[target].is_mob> || <[target].is_npc>):
          - ratelimit <player> <script[item_force_pull].flag[variables.base_cooldown]>
          - itemcooldown <item[item_force_pull].material> duration:<script[item_force_pull].flag[variables.base_cooldown]>
          - push <[target]> origin:<[target].location> destination:<player.location.forward[1.5]> no_rotate speed:<script[item_force_pull].flag[variables.base_strength].mul[0.4]> duration:<script[item_force_pull].flag[variables.base_duration]>
          - flag <player> player.force.statistics.cast_pull:++

force_heal:
    type: task
    script:
        - ratelimit <player> <script[item_force_heal].flag[variables.base_cooldown]>
        - itemcooldown <item[item_force_heal].material> duration:<script[item_force_heal].flag[variables.base_cooldown]>
        - cast slow <player> amplifier:1 duration:<script[item_force_heal].flag[variables.base_duration]> no_clear no_icon hide_particles
        - define playerLoc <player.location>
        - flag <player> healing
        - flag <player> player.force.statistics.cast_heal:++
        - define target <player.eye_location.ray_trace_target[ignore=<player>;range=<script[item_force_heal].flag[variables.base_range]>;raysize=0.2]||<player>>
        - if <[target]> != <player> && (<[target]> != null || (<[target].is_player> || <[target].is_mob> || <[target].is_npc>)):
            - repeat <script[item_force_heal].flag[variables.base_duration]>:
                - wait <script[item_force_heal].flag[variables.base_duration].div[8]>
                - if !<player.flag[healing]> || <player.location.distance[<[playerLoc]>]> > 0.5:
                    - cast slow remove <player>
                    - flag <player> healing:!
                    - stop
                - define target <player.eye_location.ray_trace_target[ignore=<player>;range=<script[item_force_heal].flag[variables.base_range]>;raysize=0.15]||<player>>
                - if <[target]> != null || (<[target].is_player> || <[target].is_mob> || <[target].is_npc>):
                    - heal <[target]> <script[item_force_heal].flag[variables.base_strength].div[2]>
                    - narrate "healing target: <[target].name>"
        - else if <[target]> == <player>:
            - repeat <script[item_force_heal].flag[variables.base_duration]>:
                - wait <script[item_force_heal].flag[variables.base_duration].div[8]>
                - if !<player.flag[healing]> || <player.location.distance[<[playerLoc]>]> > 0.5:
                    - cast slow remove <player>
                    - flag <player> healing:!
                    - stop
                - heal <[target]> <script[item_force_heal].flag[variables.base_strength].div[2]>
                - narrate "healing target: <[target].name>"

force_choke:
    type: task
    script:
        - define target <player.eye_location.ray_trace_target[ignore=<player>;range=<script[item_force_choke].flag[variables.base_range]>]||<player>>
        - if <[target]> != null && (<[target].is_player> || <[target].is_mob> || <[target].is_npc>):
            - ratelimit <player> <script[item_force_choke].flag[variables.base_cooldown]>
            - itemcooldown <item[item_force_choke].material> duration:<script[item_force_choke].flag[variables.base_cooldown]>
            - flag <player> player.force.statistics.cast_choke:++
            - cast slow <[target]> duration:<script[item_force_choke].flag[variables.base_duration].add[0.5]> amplifier:3 hide_particles:true no_icon:true no_clear
            - cast slow <player> duration:<script[item_force_choke].flag[variables.base_range].sub[1]> amplifier:1 hide_particles:true no_icon:true no_clear
            - wait 0.25s
            - repeat <script[item_force_choke].flag[variables.base_duration].add[1]>:
                - hurt <script[item_force_choke].flag[variables.base_strength]> <[target]> cause:Magic
                - wait <script[item_force_choke].flag[variables.base_duration].sub[0.25].div[6]>

force_levitate:
    type: task
    script:
        - define target <player.eye_location.ray_trace_target[ignore=<player>;range=<script[item_force_levitate].flag[variables.base_range]>;raysize=0.35]||null>
        - if <[target]> != null && (<[target].is_player> || <[target].is_mob> || <[target].is_npc>):
            - ratelimit <player> <script[item_force_levitate].flag[variables.base_cooldown]>
            - itemcooldown <item[item_force_levitate].material> duration:<script[item_force_levitate].flag[variables.base_cooldown]>
            - cast levitation <[target]> amplifier:<script[item_force_levitate].flag[variables.base_strength].sub[1]> duration:<script[item_force_levitate].flag[variables.base_duration]> hide_particles no_icon no_clear
            - adjust <[target]> speed:0
            - flag <player> player.force.statistics.cast_levitate:++

force_leap:
    type: task
    script:
        - ratelimit <player> <script[item_force_leap].flag[variables.base_cooldown]>
        - itemcooldown <item[item_force_leap].material> duration:<script[item_force_leap].flag[variables.base_cooldown]>
        - push <player> origin:<player.location> destination:<player.location.forward[<script[item_force_leap].flag[variables.base_range]>]> speed:<script[item_force_leap].flag[variables.base_strength]> duration:<script[item_force_leap].flag[variables.base_duration]> no_rotate
        - flag <player> player.force.statistics.cast_leap:++

force_blinding:
    type: task
    script:
        - define target <player.eye_location.ray_trace_target[ignore=<player>;range=<script[item_force_blinding].flag[variables.base_range]>;raysize=0.35]||null>
        - if <[target]> != null:
            - ratelimit <player> <script[item_force_blinding].flag[variables.base_cooldown]>
            - itemcooldown <item[item_force_blinding].material> duration:<script[item_force_blinding].flag[variables.base_cooldown]>
            - flag <player> player.force.statistics.cast_blinding:++
            - if <[target].is_player>:
                - cast blindness <[target]> amplifier:<script[item_force_blinding].flag[variables.base_strength]> duration:<script[item_force_blinding].flag[variables.base_duration]> hide_particles no_icon no_ambient no_clear
            - if <[target].is_mob>:
                - adjust <[target]> is_aware:false
                - hurt 0.01 <[target]>
                - wait <script[item_force_blinding].flag[variables.base_duration]>
                - adjust <[target]> is_aware:true
            - if <[target].is_npc> && <[target].has_trait[sentinel]>:
                - define <[target].range> original_range
                - adjust <[target]> range:0
                - wait <script[item_force_blinding].flag[variables.base_duration]>
                - if <[original_range]> == 0:
                    - adjust <[target]> range:20
                    - narrate "Targetting npcs might be broken. If it doesnt work, contact JustinS_2006"
                - else:
                    - adjust <[target]> range:<[original_range]>

force_stun:
    type: task
    script:
    - define target <player.eye_location.ray_trace_target[ignore=<player>;range=<script[item_force_stun].flag[variables.base_range]>;raysize=0.35]||null>
    - if <[target]> != null && (<[target].is_player> || <[target].is_mob> || <[target].is_npc>):
        - ratelimit <player> <script[item_force_stun].flag[variables.base_cooldown]>
        - itemcooldown <item[item_force_stun].material> duration:<script[item_force_stun].flag[variables.base_cooldown]>

        - adjust <[target]> speed:<element[2].power[<script[item_force_stun].flag[variables.base_strength].mul[-1.5].sub[1.55]>].div[5]>
        - cast jump <[target]> duration:<script[item_force_stun].flag[variables.base_duration]> amplifier:150 hide_particles:true no_clear:true no_icon:true
        - cast confusion <[target]> duration:<script[item_force_stun].flag[variables.base_duration].add[3]> amplifier:10 hide_particles:true no_clear:true no_icon:true

        - wait <script[item_force_stun].flag[variables.base_duration].div[2]>
        - adjust <[target]> speed:<element[2].power[<script[item_force_stun].flag[variables.base_strength].mul[-1.5].sub[1.55]>].div[4]>

        - wait <script[item_force_stun].flag[variables.base_duration].div[4]>
        - adjust <[target]> speed:<element[2].power[<script[item_force_stun].flag[variables.base_strength].mul[-1.5].sub[1.55]>].div[2.5]>

        - wait <script[item_force_stun].flag[variables.base_duration].div[4]>
        - adjust <[target]> speed:0.1



forcepowers_inventory:
    type: inventory
    inventory: chest
    title: Force_Powers
    gui: false
    slots:
        - [] [] [] [] [] [] [] [] []
        - [] [] [] [] [] [] [] [] []
        - [] [] [] [] [] [] [] [] []
        - [] [] [] [] [] [] [] [] []

player_movement_detection:
    type: world
    events:
       on player jumps flagged:healing:
        - flag player healing:!

give_powers:
    type: command
    name: givepowers
    description: coolio
    usage: /givepowers
    script:
        - if <context.args> == 1:
            - define playerName <context.args.get[1]>
            - define playerToGive <server.match_player[<[playerName]>].if_null[null]>
            - if <[playerToGive]> == null:
                - narrate "<&[error]>Can't find player by name '<&[emphasis]><[playerName]><&[error]>'!"
                - stop
            - if !<[playerToGive].has_flag[force_inv_open]>:
                - run switch_inventory_script def.def_target:<[playerToGive]>
            - give item_force_push player:<[playerToGive]>
            - give item_force_pull player:<[playerToGive]>
            - give item_force_heal player:<[playerToGive]>
            - give item_force_choke player:<[playerToGive]>
            - give item_force_levitate player:<[playerToGive]>
            - give item_force_leap player:<[playerToGive]>
            - give item_force_blinding player:<[playerToGive]>
            - give item_force_stun player:<[playerToGive]>
        - else if <context.args> > 1:
            - narrate "<&[error]>Incorrect usage! Use: /givepowers [player]"
            - stop
        - else if <context.args.is_empty>:
            - if <player> == null:
                - narrate "<&[error]>Can't find this player???   ERROR CODE: 0003"
                - stop
            - if !<[playerToGive].has_flag[force_inv_open]>:
                - run switch_inventory_script
            - give item_force_push
            - give item_force_pull
            - give item_force_heal
            - give item_force_choke
            - give item_force_levitate
            - give item_force_leap
            - give item_force_blinding
            - give item_force_stun




initialize_variables:
    type: command
    name: initializeforcevariables
    description: run me when using the plugin for the first time
    usage: /initializeforcevariables
    script:
        - narrate "Initializing force variables. Don't run me again, ever, unless JustinS_2006 tells you to do so or you want to reset all variables to their original value"

        - define push <script[item_force_push]>
        - flag <[push]> variables.base_strength:4
        - flag <[push]> variables.base_duration:2
        - flag <[push]> variables.base_cooldown:3
        - flag <[push]> variables.base_range:11
        - flag <[push]> variables.energy_cost:3
        - flag <[push]> variables.display_colour:blue

        - define pull <script[item_force_pull]>
        - flag <[pull]> variables.base_strength:2
        - flag <[pull]> variables.base_duration:2
        - flag <[pull]> variables.base_cooldown:3
        - flag <[pull]> variables.base_range:15
        - flag <[pull]> variables.energy_cost:3
        - flag <[pull]> variables.display_colour:blue

        - define heal <script[item_force_heal]>
        - flag <[heal]> variables.base_strength:2
        - flag <[heal]> variables.base_duration:8
        - flag <[heal]> variables.base_cooldown:12
        - flag <[heal]> variables.base_range:8
        - flag <[heal]> variables.energy_cost:8
        - flag <[heal]> variables.display_colour:blue

        - define choke <script[item_force_choke]>
        - flag <[choke]> variables.base_strength:1
        - flag <[choke]> variables.base_duration:5
        - flag <[choke]> variables.base_cooldown:8
        - flag <[choke]> variables.base_range:13
        - flag <[choke]> variables.energy_cost:6

        - define levitate <script[item_force_levitate]>
        - flag <[levitate]> variables.base_strength:1
        - flag <[levitate]> variables.base_duration:3
        - flag <[levitate]> variables.base_cooldown:7
        - flag <[levitate]> variables.base_range:13
        - flag <[levitate]> variables.energy_cost:5

        - define leap <script[item_force_leap]>
        - flag <[leap]> variables.base_strength:0.9
        - flag <[leap]> variables.base_duration:0.8
        - flag <[leap]> variables.base_cooldown:4
        - flag <[leap]> variables.base_range:6
        - flag <[leap]> variables.energy_cost:4

        - define blind <script[item_force_blinding]>
        - flag <[blind]> variables.base_strength:1
        - flag <[blind]> variables.base_duration:3
        - flag <[blind]> variables.base_cooldown:7
        - flag <[blind]> variables.base_range:13
        - flag <[blind]> variables.energy_cost:5

        - define stun <script[item_force_stun]>
        - flag <[stun]> variables.base_strength:1
        - flag <[stun]> variables.base_duration:5
        - flag <[stun]> variables.base_cooldown:5
        - flag <[stun]> variables.base_range:11
        - flag <[stun]> variables.energy_cost:5

# The following scripts are item scripts for each force power:

item_force_push:
    type: item
    material: allay_spawn_egg
    mechanisms:
       custom_model_data: 100
    display name: <&b><bold>Push
    ##lore:

item_force_pull:
    type: item
    material: axolotl_spawn_egg
    mechanisms:
       custom_model_data: 100
    display name: <&b><bold>Pull
    ##lore:

item_force_heal:
    type: item
    material: bat_spawn_egg
    mechanisms:
       custom_model_data: 100
    display name: <red><bold>Heal
    ##lore:

item_force_choke:
    type: item
    material: bee_spawn_egg
    mechanisms:
       custom_model_data: 100
    display name: <dark_gray><bold>Choke
    ##lore:

item_force_levitate:
    type: item
    material: blaze_spawn_egg
    mechanisms:
       custom_model_data: 100
    display name: <&b><bold>Levitate
    ##lore:

item_force_leap:
    type: item
    material: camel_spawn_egg
    mechanisms:
       custom_model_data: 100
    display name: <green><bold>Leap
    ##lore:

item_force_blinding:
    type: item
    material: cat_spawn_egg
    mechanisms:
       custom_model_data: 100
    display name: <dark_gray><bold>Blinding
    ##lore:

item_force_stun:
    type: item
    material: cave_spider_spawn_egg
    mechanisms:
       custom_model_data: 100
    display name: <yellow><bold>Stun
    ##lore: