Paste #48923: Untitled Paste

Date: 2018/08/10 08:35:47 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


EarthArmor:
    type: world
    debug: true
    events:
        on player right clicks with item:
            - if <player.has_flag[element_toggled]> {
                - queue clear
            }
            - if <player.flag[element]> == earth {
                - if <player.location.cursor_on[3].material> == m@air {
                    - if <player.has_flag[armorcooldown]> {
                        - playsound <player.location> sound:BLOCK_ANVIL_PLACE volume:0.15
                        - queue clear
                    }
                    - if <player.has_flag[armorhealth]> {
                        - queue clear
                    }
                    - define hardscale <li@m@sand|m@clay|m@dirt|m@grass|m@gravel|m@diorite|m@cobblestone|m@stone|m@polished_diorite|m@andesite|m@polished_andesite|m@granite|m@polished_granite>
                    - if !<def[hardscale].contains[<player.location.add[0,-1,0].material>]> {
                        - queue clear
                    }
                    - flag <player> source:<player.location.add[0,-1,0].material>
                    - flag <player> sourceloc:<player.location.add[0,-1,0]>
                    - playeffect <player.location> effect:blockdust_<player.location.add[0,-1,0].material.id> quantity:250
                    - repeat 15 {
                        - playsound <player.location> sound:BLOCK_STONE_BREAK volume:100000000000
                    }
                    - modifyblock <player.flag[sourceloc]> m@air
                    - flag <player> armorhealth:<def[hardscale].find[<player.flag[source]>].mul[5]>
                }
            }
        on player damaged:
            - if <player.has_flag[armorhealth]> {
                - flag <player> armorhealth:<player.flag[armorhealth].sub[<context.damage>]>
                - determine passively cancelled
                - if <player.flag[armorhealth]> <= 0 {
                    - modifyblock <player.flag[sourceloc]> <player.flag[source]>
                    - playeffect <player.location.points_between[<player.flag[sourceloc]>]> effect:blockdust_<player.flag[source].as_material.id> quantity:250 offset:0,0,0
                    - repeat 15 {
                        - playsound <player.location> sound:BLOCK_STONE_BREAK volume:100000000000
                    }
                    - flag <player> armorhealth:!
                    - flag <player> source:!
                    - flag <player> sourceloc:!
                    - flag <player> armorcooldown duration:30s
                }
            }