Paste #123093: Choker

Date: 2024/05/26 04:28:54 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


force_choke:
    type: task
    definitions: target
    script:
        - if <[target]> != null && (<[target].is_player> || <[target].is_mob> || <[target].is_npc>):
            - flag <player> player.force.statistics.cast_choke:++
            - cast slow <[target]> duration:<script[item_force_choke].flag[variables.base_duration].sub[0.25].div[6].add[0.4]> 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

            # Prevent other force powers from being used when healing
            - foreach <player.flag[player.force.force_powers_list].exclude[force_choke]> as:power:
                - define expiration <script[item_force_choke].flag[variables.base_duration]>
                - define old_cooldown <player.flag_expiration[player.force.cooldown.<[power]>].second||0>
                - if <[old_cooldown]> > <[expiration]>:
                    - foreach next
                - flag <player> player.force.cooldown.<[power]> expire:<[expiration]>
                - itemcooldown <item[item_<[power]>].material> duration:<[expiration]>
            - define previous_target <[target]>
            - repeat <script[item_force_choke].flag[variables.base_duration].add[1]>:
                - define target <player.eye_location.ray_trace_target[ignore=<player>;range=<script[item_force_choke].flag[variables.base_range]>;raysize=<script[item_force_choke].flag[variables.ray_size]>]||null>
                - if ( <[target]> != null && <[previous_target]> != null ) && ( <[target].is_player> || <[target].is_mob> || <[target].is_npc> ):
                    - if <[target]> != <[previous_target]>:
                        - cast slow remove <[previous_target]>
                        - cast slow <[target]> duration:<script[item_force_choke].flag[variables.base_duration].sub[0.25].div[6].add[0.4]> amplifier:3 hide_particles:true no_icon:true no_clear
                    - if <[target].health.sub[<script[item_force_choke].flag[variables.base_strength]>]> <= 0:
                        - hurt <script[item_force_choke].flag[variables.base_strength]> <[target]> cause:Magic
                        - define target null
                        - define previous_target null
                        - repeat next
                    - hurt <script[item_force_choke].flag[variables.base_strength]> <[target]> cause:Magic
                    - define previous_target <[target]>
                - else if <[target]> == null && <[previous_target]> != null:
                        - define previous_target <[target]>
                        - wait <script[item_force_choke].flag[variables.base_duration].sub[0.25].div[6]>
                        - repeat next
                - else if <[target]> != null && <[previous_target]> == null:
                    - cast slow <[target]> duration:<script[item_force_choke].flag[variables.base_duration].sub[0.25].div[6].add[0.4]> amplifier:3 hide_particles:true no_icon:true no_clear
                    - hurt <script[item_force_choke].flag[variables.base_strength]> <[target]> cause:Magic
                    - define previous_target <[target]>
                - else if <[target]> == null && <[previous_target]> == null:
                    - cast slow remove <player>
                    - foreach <player.flag[player.force.force_powers_list].exclude[force_choke]> as:power:
                        - narrate "maybe nothing happens"
                        - if !<player.has_flag[player.force.cooldown.<[power]>]>:
                            - foreach next
                        # if the old cooldown > new expiration, dont change anything. If it's less or equal, set it to 0
                        - if <[old_cooldown]> <= <[expiration]>:
                            - flag <player> player.force.cooldown.<[power]>:!
                            - itemcooldown <item[item_<[power]>].material> duration:0
                    - stop
                - wait <script[item_force_choke].flag[variables.base_duration].sub[0.25].div[6]>